Welcome to DevAuthority.Com Sign in | Join | Help



<April 2007>
SuMoTuWeThFrSa
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Navigation

Syndication


XSDClassgen v 2.0.3 Released

Folks,

After numerous promises to fix all the parsing issues, I finally had time to get to it. The most notable enhancements in XSDClassgen v 2.0.3  are

Better parsing engine: The new codebase has been completely re-written using the XMLSchemaImporter and XmlCodeExporter classes. More information could be found here. In short now all the grunt work of parsing the schema is handed over to the .net framework. This makes the parsing engine more robust.

Console Application: A command line version to generate the code. This opens the door to include code generation as an prebuild event (Project, Properties, Build Events, Pre-Build event command line) . So in a typical scenario, developer would create a pre-build event in the IDE and include it as part of every build. This eliminates the manual event of the developer having to create the source code file every time XSD is modified.

Sample command line

XSDClassGenConsole.exe /lang:c# /xsdpath:"D:\Current Projects\Schemas\DEM.xsd" /ns:"samples.Pubs"  /filename:"Samples.Pubs" /folder:"D:\output"  /partial  /nullable /initialize

I have tested all the schemas that were reported to fail because of parsing issues in the previous builds and it seem to work fine now.

As usual feedbacks are welcome. One thing I have in mind for the future release is to have XSD integrated with the cutom tool generation option.

 

Download latest version of XSDClassgen

Published Sunday, April 01, 2007 10:33 AM by Ram Marappan
Attachment(s): Release_2.0.5.zip

Comments

# Does this release support xsd:import @ Monday, April 02, 2007 6:52 AM

I have a base schema:
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:doc="http://foo/bar/1.0"
xmlns:f="http://foo/extension/1.0"
xmlns:j="http://www.it.ojp.gov/jxdm/3.0.3"
targetNamespace="http://foo/bar/1.0"
>

<xsd:import namespace="http://foo/extension/1.0"
schemaLocation=".\f_extension.xsd"/>

<xsd:import namespace="http://www.it.ojp.gov/jxdm/3.0.3"
schemaLocation=".\jxdm\3.0.3\jxdm.xsd"/>

<xsd:element name="bar" type="doc:barType"/>

<xsd:complexType name="barType">
<xsd:annotation>
<xsd:documentation> </xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="j:DocumentType">
<xsd:sequence>
<xsd:element ref="f:Case"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>

Which errors out with:
Error while compiling schema file, Message: Undefined complexType 'http://www.it.ojp.gov/jxdm/3.0.3:DocumentType' is used as a base for complex type extension.

The file exists where the schemaLocation points.  

The xsdObjectGen utility will create the classes.  However without generic support and all the other goodies you have added.

Any chance this will be supported some time soon?  

Thanks

schallm

# re: XSDClassgen v 2.0.3 Released @ Monday, April 02, 2007 5:35 PM

Schallm,

Can you send me the XSD that is causing problems. If that's something that could be fixed quickly, I will look in to fixing it.

Ram

Ram Marappan

# re: XSDClassgen v 2.0.3 Released @ Tuesday, April 03, 2007 7:54 AM

What is your email?  I couldn't find it in your profile.

schallm

# re: XSDClassgen v 2.0.3 Released @ Wednesday, April 04, 2007 12:26 PM

I tried to run this on the KML schema written by Google Earth, but when compiling get a few errors.

The schema is found at: http://code.google.com/apis/kml/schema/kml21.xsd

The error seems pretty obvious:
...
public partial class LinearRingType : GeometryType
   {
// ...      
       public bool m_extrude;

// ... error is in the constructor
       
       public LinearRingType()
       {
           this.extrudeField = false;
//...
       }
       
       [XmlIgnore()]
       public bool Extrude
       {
           get
           {
               return this.m_extrude;
           }
           set
           {
               this.m_extrude = value;
           }
       }
....

it should say this.Extrude, no?

Thanks, legion80

legion80

# re: XSDClassgen v 2.0.3 Released @ Wednesday, April 04, 2007 12:44 PM

We are extending the jxdm schema, but the base schema won't build either.  You can download this schema from:

http://it.ojp.gov/jxdm/3.0.3/jxdm-3.0.3.zip

unzip to a folder and then try to run XSDClassGen against <folder>\jxdm\3.0.3\jxdm.xsd

I get the following error:
Error while compiling schema file, Message: Type 'http://www.it.ojp.gov/jxdm/3.0.3/proxy/xsd/1.0:decimal' is not declared.

We are currently using xsd.exe directly which is horrible to work with. :(

Thanks for looking at it.

schallm

# re: XSDClassgen v 2.0.3 Released @ Thursday, April 05, 2007 8:28 AM

Folks,

I will take a look at all the issues over teh weekend.

Thanks
Ram

Ram Marappan

# re: XSDClassgen v 2.0.3 Released @ Friday, April 06, 2007 8:12 PM

Folks,

I have fixed the issues associated with the http://code.google.com/apis/kml/schema/kml21.xsd. The latest release is XSDClassgen v 2.0.4

Please let me know if you guys see any issues.

Ram

Ram Marappan

# re: XSDClassgen v 2.0.3 Released @ Monday, April 09, 2007 7:09 AM

Hi Ram,

Thanks for taking the time to fix the bug.

It compiles fine, but serialization creates an exception, and I think it has to do with the abstract classes.

(I'm still using Google's KML Schema here)

"The type DocumentType was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."

DocumentType is a FeatureType, which is an ObjectType.

The output for KmlType.Item (a FeatureType property) from xsd.exe is:

   /// <remarks/>
   [XmlElement( "Document", typeof( DocumentType ) )]
   [XmlElement( "Folder", typeof( FolderType ) )]
   [XmlElement( "GroundOverlay", typeof( GroundOverlayType ) )]
   [XmlElement( "NetworkLink", typeof( NetworkLinkType ) )]
   [XmlElement( "Placemark", typeof( PlacemarkType ) )]
   [XmlElement( "ScreenOverlay", typeof( ScreenOverlayType ) )]
   public FeatureType Item
   {
     get
     {
       return this.itemField;
     }
     set
     {
       this.itemField = value;
     }
   }

So it seems that xsd includes XmlIncludeAttribute for all possible subclasses.

XSDClassGen output is generated a little differently (the vars output rather than the props) but I imagine the code would be the same.

I don't know how long it would take to put this in, but anything you can do would be great.  Thanks again.

legion80

# re: XSDClassgen v 2.0.3 Released @ Wednesday, April 11, 2007 5:47 AM

Great tool! I am having a problem parsing the following schema:
http://ns.hr-xml.org/2_4/HR-XML-2_4/StandAlone/ApplicationAcknowledgement.xsd

I think it is having trouble with the import <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>

It would be great to get this working!

Thanks!!

MrCharles

# re: XSDClassgen v 2.0.3 Released @ Thursday, April 12, 2007 3:22 AM

Hi There,

I tried using your program but I noticed a couple of issues with the XSD I am using:

- All my XmlAttributes ar generated as XmlElements (thus making me have to check each element by hand to see whether it's supposed to be an node-element or an attribute)

- I have a xsd choice with two different child nodes.. your tool does generate a List<> with the name Items where these twho child nodes fit into.. but when using them and deserializing I get a exception stating the child element is not expected there.

Is there a special way to deserialise/serialize with the classes your tool generates? (different from the normal method that can be used for the output of the classes generated by xsd.exe?)

I wouldn't mind sending you some files so you can see it for yourself.

Kind regards,
Zeno.

mr.zeno

# re: XSDClassgen v 2.0.3 Released @ Sunday, April 15, 2007 7:37 PM

Folks,

I have fixed some of the issues reported by legion80. The new release id v2.0.5. For the other issues I have not had a chance to look into it. I will try to take a stab over the week.

Thanks
Ram

Ram Marappan

# re: XSDClassgen v 2.0.3 Released @ Monday, April 16, 2007 4:23 AM

Ram,

As a followup to my initial post, it looks like, according to the error message in the log, XsdClassGen is not adding an imported schema to the validation schemaSet object. So, when you compile the SchemaSet it cannot find any references to the schema taht was supposed to imported. This is only a guess using the error message (see below).

Thanks Ram!

Great Work!

*********************************************
Exception Type: System.FormatException
Message: Error while compiling schema file, Message: The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void ValidationCallBack(System.Object, System.Xml.Schema.ValidationEventArgs)
HelpLink: NULL
Source: XSDClassGenLib

StackTrace Information
*********************************************
  at Binarystrokes.Apps.XSDClassGen.Lib.SchemaProcessor.ValidationCallBack(Object sender, ValidationEventArgs args)
  at System.Xml.Schema.BaseProcessor.SendValidationEvent(XmlSchemaException e, XmlSeverityType severity)
  at System.Xml.Schema.Compiler.CompileAttribute(XmlSchemaAttribute xa)
  at System.Xml.Schema.Compiler.CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy)
  at System.Xml.Schema.Compiler.CompileComplexType(XmlSchemaComplexType complexType)
  at System.Xml.Schema.Compiler.Compile()
  at System.Xml.Schema.Compiler.Execute(XmlSchemaSet schemaSet, SchemaInfo schemaCompiledInfo)
  at System.Xml.Schema.XmlSchemaSet.Compile()
  at Binarystrokes.Apps.XSDClassGen.Lib.SchemaProcessor.compileSchema(FileStream xsdStream)
  at Binarystrokes.Apps.XSDClassGen.Lib.SchemaProcessor.GenerateObjectGraph()
  at Binarystrokes.Apps.XSDClassGen.Windows.frmMain.btnOK_Click(Object sender, EventArgs e)

MrCharles

# re: XSDClassgen v 2.0.3 Released @ Tuesday, April 17, 2007 8:23 AM

Charles,

I will take a look as quickly as possible.

Ram Marappan

# Namespaces @ Friday, April 20, 2007 1:03 AM

First, thanks for a great tool Ram, it has really helped me a lot!

We are using the generated objects when we are creating web services.

How ever we have some problem with the namespaces in our WSDL's.  

I can fix this if I do some changes to the generated code and change the namespace instead of using the constant in  XsdConstants.Ns and also change the XmlSchemaForm to Qualified instead of Unqualified.

Example:

[XmlType(TypeName="DeliveryInterface", Namespace="urn:world-com:schemas:int07_send_delivery")]
public partial class DeliveryInterface
{
        [EditorBrowsable(EditorBrowsableState.Never)]
[XmlElement(Form=XmlSchemaForm.Qualified, ElementName="DELIVERY_LINE")]
public List<Delivery> m_dELIVERY_LINECollection;

I can understand that the namespace is not easy to fix (we still want our .NET namespaces) but maybe place the XML namespaces in the ID tag for an object in XSD would be a way to solve this?

XmlSchemaForm always sets to Unqualified even if I change the form property to qualified in the XSD. Is it possible for the ClassGen to read the value from the XSD?  

Thanks
StefanB

stefanb

# re: XSDClassgen v 2.0.3 Released @ Tuesday, April 24, 2007 3:43 AM

I thing I might found a bug in the generator (it worked fine in earlier versions).

Look at this example schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:complexType name="Person">
       <xs:sequence>
           <xs:element name="Name" type="xs:string" />
           <xs:element name="Phone" type="xs:string" />
           <xs:element name="Cars" type="Cars" />
       </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Cars">
       <xs:sequence>
           <xs:element name="CarArray" type="Car" maxOccurs="unbounded" />
       </xs:sequence>
   </xs:complexType>
   <xs:complexType name="Car">
       <xs:sequence>
           <xs:element name="Model" type="xs:string" />
           <xs:element name="Engine" type="xs:string" />
       </xs:sequence>
   </xs:complexType>
</xs:schema>

The object person should have an instance of the object Cars but instead the person has a list<> of the object Car. This is the generated code:

[XmlElement(Form=XmlSchemaForm.Unqualified, ElementName="Cars")]
public List<Car> m_carsCollection;

When it should look like this:

[XmlElement(Form=XmlSchemaForm.Unqualified, ElementName="Cars")]
public Cars m_cars;

If I add a dummy element on the object Cars it will generate the correct Cars on the person and not the List<Car>. Example:

<xs:complexType name="Cars">
   <xs:sequence>
       <xs:element name="CarArray" type="Car" maxOccurs="unbounded" />
       <xs:element name="ignore" type="xs:string" />
   </xs:sequence>
</xs:complexType>

Cheers

stefanb

# XmlSchemaException... @ Friday, May 04, 2007 12:40 PM

I was running XSDClassGen 2.0.5 on http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd and received the following error:

Exception Type: System.Xml.Schema.XmlSchemaException
SourceUri:
LineNumber: 297

Thanks,

John

johnwebbcole

# Issue with collections when using Nullable<> option @ Friday, May 25, 2007 1:40 PM

Great tool - much more usable code than xsd.exe.  One issue I've come across:

The following xsd generates fine when I don't use the 'create value types as Nullable<t>' option (ie, I get "public List<Membership> m_membershipCollection").  However, with this option checked it generates "public Nullable<Membership> m_membership" instead of the expected List<T>.  This seems to work fine with string collections (as in OtherMembership).:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Memberships" targetNamespace="http://www.mynamespace.com/Memberships.xsd" elementFormDefault="qualified" xmlns="http://www.mynamespace.com/Memberships.xsd" xmlns:mstns="http://www.mynamespace.com/Memberships.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.1">
<xs:element name="Memberships">
<xs:complexType>
<xs:sequence>
<xs:element name="Membership" type="Membership" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="OtherMembership" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="Membership">
<xs:restriction base="xs:string">
<xs:enumeration value="Class A" />
<xs:enumeration value="Class B" />
<xs:enumeration value="Class C" />
<xs:enumeration value="Class D" />
<xs:enumeration value="Class E" />
</xs:restriction>
</xs:simpleType>
</xs:schema>

jomo

# re: XSDClassgen v 2.0.3 Released @ Tuesday, June 19, 2007 3:56 AM

Compliments for this tool. It works fine, but I get an problem running it on the following XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:qry="urn:st-com:ST:FAP:MES:qry" xmlns:FAP="urn:st-com:ST:FAP" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:st-com:ST:FAP:MES:qry" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="../QRYdata.xsd"/>
<xs:element name="ReasonCodeListTxRequest" type="qry:ReasonCodeListTxRequestType"/>
<xs:complexType name="ReasonCodeListTxRequestType">
<xs:all>
<xs:element ref="qry:BUSINESSRULE"/>
<xs:element ref="qry:TRANSACTION"/>
<xs:element ref="qry:USERID"/>
<xs:element ref="qry:REASONCATEGORY"/>
<xs:element ref="qry:WORKAREA" minOccurs="0"/>
<xs:element ref="qry:EQPTYPE" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:schema>


This schema produces the following C# class:

[System.CodeDom.Compiler.GeneratedCodeAttribute("XSDClassGenConsole", "2.0.5.0")]
   [System.Diagnostics.DebuggerStepThroughAttribute()]
   [System.ComponentModel.DesignerCategoryAttribute("code")]
[Serializable()]
[XmlRoot()]
[XmlType(TypeName="ReasonCodeListTxRequestType", Namespace=XsdConstants.Ns)]
public partial class ReasonCodeListTxRequestType
{
 [EditorBrowsable(EditorBrowsableState.Never)]
 [XmlElement(Form=XmlSchemaForm.Unqualified, ElementName="BUSINESSRULE")]
 public string m_bUSINESSRULE;
....
....
....
}

(I've omitted the rest of the code)
Note that the attribute XmlType sets the TypeName of the class to "ReasonCodeListTxRequestType" while  
I need the name "ReasonCodeListTxRequest" (as defined into the XSD). It is possible to change this behaviour or I have to parse manually the c# class changing this string?
Thanks in advance.

Giuseppe

jux72

# Can you generate xml from the C# objects? @ Friday, July 13, 2007 12:02 PM

Great work! I do have a question though. How do you extract the xml out of the objects (kinda like: MyObject.ToXml() ) which would produce an xml string representation of the xml object model?

Thanks and again keep it up!

cpeele

# re: XSDClassgen v 2.0.3 Released @ Friday, August 31, 2007 1:44 PM

When deserializing with v 2.0.5 we are getting nulls for all the xml object values.

Any ideas.

Smoov

# re: XSDClassgen v 2.0.3 Released @ Tuesday, October 09, 2007 9:41 AM

Just checking if anything has been addressed with MrCharles post?  I have the same issue.

Thanks for the great tool!

scottskiblack

# re: XSDClassgen v 2.0.3 Released @ Tuesday, October 23, 2007 5:14 AM

Great tool!! I experienced only one drawback... and am therefore compelled into using XsdObjectGen (without all type strong Generics... :'( ).

-> No support for multiple namespaces.

XsdObjectGen has an -y: parameter in wich you can supply additional namespaces.

Example: We use a BusinessObjectModel wich is in its own namespace and we use a ServiceInterfaceModel wich is in it's own namespace as well... But... It uses BusinessObjectModel objects also.

I hope this feature will come to the tool soon so we can finally generate a type strong objectmodel! :)

TeknoGecko

# re: XSDClassgen v 2.0.5 Released --- Error @ Tuesday, November 20, 2007 8:20 AM


I am getting the following Error :Error 1 Structure 'XsdConstants' must contain at least one instance member variable or Event declaration.

I am getting the error when I am trying to compile the Library for the generated class.

softwarevikas

Anonymous comments are disabled

Powered by Community Server, by Telligent Systems