Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSD nillable types

 
Thomas De Vos
stable boy
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

--------
Edit Comment: Disabled smiles.
[ March 08, 2004: Message edited by: Madhav Lakkapragada ]
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
stable boy
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was a great help. Many thanks.
Did you use any reference, if so, which?
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic