G
Guest
When I autogenerate class files from XSD schemas using XSD.EXE the generated
class doesn't generate instances of nested classes. Is there any way to
autocreate instances of nested classes also? I don't want to modify
autogenerated code because all changes would be lost when the class would be
regenerated.
Sample schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="element1">
<xs:complexType>
<xs:sequence>
<xs:element name="element2">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Autogenerated class
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd")
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd", IsNullable=false)]
public class element1 {
/// <remarks/>
public element1Element2 element2;
}
/// <remarks/
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd")]
public class element1Element2 {
}
class doesn't generate instances of nested classes. Is there any way to
autocreate instances of nested classes also? I don't want to modify
autogenerated code because all changes would be lost when the class would be
regenerated.
Sample schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="element1">
<xs:complexType>
<xs:sequence>
<xs:element name="element2">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Autogenerated class
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd")
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd", IsNullable=false)]
public class element1 {
/// <remarks/>
public element1Element2 element2;
}
/// <remarks/
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/XMLSchema1.xsd")]
public class element1Element2 {
}