i have a problem writing a valid XSD which describes a potential null-value for a decimal.
I’m trying to validate following XML
<RatioDe fieldId="011" nil="true"></RatioDe>
and the corresponding XSD description for this element is
<xs:element minOccurs="0" maxOccurs="1" name="RatioDe" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="fieldId" type="xs:string" />
<xs:attribute name="nil" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Basically, the errormessage is
The element ‘RatioDe’ is invalid – The value ” is not a valid ‘Decimal’ — The string ” is not a valid decimal value
At the moment i have no further idea what to change in my xsd to make the xml valid.
You need to use
xsi:nilin your instance document, not justnil, i.e.And make sure that the
xsiprefix is defined somewhere in the document (withxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance")