c# - XSD: Using Visual Studio xsd.exe not generating fixed/default values from base element set through restriction in the child element -
what want achieve have base complex type defines id , have child-specific value id along each child having additional child-specific elements. know can't achieved in 1 block defined base type, defined type sets id through restriction, , have type definition extends restricted type adding more elements.
the schema validates, when use xsd.exe tool generate classes, restricted class not set id in code @ all, resulting in id value not being set in extended class.
i have defined base complex element in following manner:
<xs:complextype name="baseelem" abstract="true"> <xs:sequence> <xs:element name="elemid" type="xs:int"/> </xs:sequence> </xs:complextype> next, added child element sets elemid value through restriction:
<xs:complextype name="baseelemfoo"> <xs:complexcontent> <xs:restriction base="baseelem"> <xs:sequence> <xs:element name="elemid" type="xs:int" final="1"/> </xs:sequence> </xs:restriction> </xs:complexcontent> </xs:complextype> finally, extend baseelemfoo add more elements , attributes:
<xs:complextype name="elemfoo"> <xs:complexcontent> <xs:extension base="baseelemfoo"> <xs:sequence> <xs:element name="firstelement" type="xs:string" /> <xs:element name="secondelement" type="xs:string" /> </xs:sequence> <xs:attribute name="firstattribute" type="xs:string"/> <xs:attribute name="secondattribute" type="xs:string"/> </xs:extension> </xs:complexcontent> </xs:complextype> after running xsd.exe (parameters /c , /n) generate classes elements of type, elemid never set 1 , baseelemfoo inherits baseelem, empty.
is there way make xsd.exe generate class elemfoo elemid value set 1?
Comments
Post a Comment