Substitute default value for missing element

kuangft

New Member
An excerpt of my schema:\[code\]<xs:complexType name="foo"> <xs:sequence> <xs:element name="bar" type="xs:positiveInteger"/> <xs:element name="baz" type="bax_type" minOccurs="0"/> </xs:sequence></xs:complexType><xs:simpleType name="baz_type"> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="http://stackoverflow.com/questions/11449798/none"/> <xs:enumeration value="http://stackoverflow.com/questions/11449798/wombat"/> </xs:restriction></xs:simpleType>\[/code\]That is, I've got an an element of an enumeration type which can be missing. Is it possible to get the following behavior:[*]On the following XML it gives the default value of \[code\]none\[/code\] instead of \[code\]null\[/code\] - i.e. \[code\]foo.getBaz() == BazType.NONE\[/code\]This XML should be valid for backward compatibility.\[code\] <foo> <bar>1</bar> </foo>\[/code\][*]This one parses correctly:\[code\]<foo> <bar>1</bar> <baz>wombat</baz></foo>\[/code\]
 
Back
Top