I have an xml with an xml-schema. The xml-schema defines an abstract complex type with 2 optional attributes that have default values. Then I have several complex types that extend the base one. And finally nodes of the types defined. So I load the xml and when I parse each node, the optional attributes are not present at all. I've tried fooling around with the namespaces, even:
XML.ignoreProcessingInstructions = false;
No luck. Something similar was being experienced by this guy on codingforums, but that was like 5 years ago. Same is happening to me with firefox 3.0.11 - the xml is shown without the default attributes. For now I'm setting the default values in code, but isn't there a way to make them available from the xml-schema?
Sample XML-schema:
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myorg.org" xmlns:tns="http://www.myorg.org" elementFormDefault="qualified">
<element name="config" type="tns:FieldsNode"></element>
<complexType name="FieldsNode">
<choice minOccurs="0" maxOccurs="unbounded">
<element name="ImagePicker" type="tns:ImagePickerNode"
maxOccurs="unbounded" minOccurs="0">
</element>
</choice>
</complexType>
<complexType name="FieldBase">
<attribute use="required" name="id" type="string"></attribute>
<attribute use="optional" default="true" name="mandatory"
type="boolean">
</attribute>
<attribute default="3" name="colspan" type="int" use="optional"></attribute>
</complexType>
<complexType name="ImagePickerNode">
<complexContent>
<extension base="tns:FieldBase">
<attribute name="maxWidth" type="int" use="required"></attribute>
<attribute name="maxHeight" type="int" use="required"></attribute>
</extension>
</complexContent>
</complexType>
Sample XML:
<config xmlns="http://www.myorg.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myorg.org test.xsd">
<ImagePicker id="somePicker" maxHeight="10" maxWidth="12"/>
<ImagePicker id="someOtherPicker" maxHeight="100" maxWidth="212" colspan="1" mandatory="false"/>
</config>
Edit: added sample xml and schema.