This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

XSD nillable types

 
stable boy
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 xs:Decimal (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 xs:Decimal are derived from xs:anySimpleType.
I'm rather confused.

--------
Edit Comment: Disabled smiles.
[ March 08, 2004: Message edited by: Madhav Lakkapragada ]
 
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
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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic