I am creating a schema for an xml coming from an external system. I have a problem modelling this type:
<main>
...
<Foo TYPE="Numeric"/>
<Bar TYPE="Numeric">12.0</Bar>
...
</main>
I have create a type extending double:
<xs:complexType name="myNumeric">
<xs:simpleContent>
<xs:extension base="xs:double">
<xs:attribute name="TYPE" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
....
<xs:element name="Foo" type="myNumeric" />
<xs:element name="Bar" type="myNumeric" />
However this is not good enough, when I am try to validate the schema I got an error complaining that: ” is not a valid value for ‘double’.
Any hints?
Thanks
xs:double cannot have an empty sting as a value. If you want to mark this type as a “null” then you can use xsi:nil=”true” to indicate that this is an “empty” double:
To allow this use nillable=”true” in your schema
You will need to include a reference to the XML Schema instance namespace in your xml instance.