Hi, During my definition of an XSD schema I encountered the following: I noticed that the nillable attribute of an element can only be used for types of type xs:string. I have seen a schema that contains a decimal defined with nillable=true. Strictly speaking I think both should be possible. However the XML derived from these schema's as <element></element> for decimal did not validate but for strings did validate. I'm unable to find any reference in the XSD schema why a xsecimal (or xs:integer) cannot be defined as nillable. Anyone? On the other hand looking at the built-in types I noticed that both xs:string and xsecimal are derived from xs:anySimpleType. I'm rather confused.
Hi thomas, You can use nillable="true" for decimal types. But you would also have to use xs:nil !!! If you needed the validation to be done,you also need to add xs:nil="true" on the empty element itself, in your document. Ex:
then the following are valid:
but the following is invalid:
But this require you to specify xs:nil in the elemnt you use So, If you dont want to use xs:nill and still be able to specify an empty value, you can define your own type as an union
Then you can declare teh elemnt as type "emptyDecimalAllowed".
Hope this helps [ March 08, 2004: Message edited by: Hari Vignesh Padmanaban ] [ March 08, 2004: Message edited by: Hari Vignesh Padmanaban ] [ March 08, 2004: Message edited by: Hari Vignesh Padmanaban ]
Thomas De Vos
Joined: Apr 12, 2003
This was a great help. Many thanks. Did you use any reference, if so, which?
Hari Vignesh Padmanaban
Joined: Oct 07, 2003
I had a similar doubt some time back ad i think i found an answer similar to this in some web site and had noted it down .. if you do a google search you would come up with the same .. I dont remember where exactly ..i think it was a question in a mailing list !!! hope this helps hari