Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Is Nillable same as an empty element  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an xsd declared as below



From the above schema, I used nillable = "true" for person but not for organization. That means I believe, nillable = false (default) for organization.

What exactly does it mean?

I wrote an xml instance based on this schema as follows



and another instance


In either case, when I validated the xml it did not give me any error or warning. So what is nillable doing here and what is the real purpose of this attribute ?
 
Ranch Hand
Posts: 728
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In either case, when I validated the xml it did not give me any error or warning.



[0] That shouldn't be the case. Both documents should be invalidated with the mention:
"...(organization | person) cannot be empty according to the DTD/Schema"
or something of the kind.

[1] For tns:organization, there is nothing we you do except complying to the schema by adding its children tns:organizationName and tns:organizationId, one each of that order with the correct text types.

[2] For tns:person, you can adding the attribute xsi:nil="true" and the document would be validated. And that is the major aspect of what nullible attribute being true meant in the schema.
 
Rajani Gummadi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm really not clear on the concept of nillable is true. What does it mean? and why did you all nill=true in xml instance.
 
g tsuji
Ranch Hand
Posts: 728
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>and why did you all nill=true in xml instance
???

It would not be surprising if it is still not clear. You have to first validate your validation algorithm as you seem to suggest there were no error and warning in both of the original documents. That can't be true and in the case of tns:organization that is even obvious. Make sure that part it is clear to you and the part of nillable would have a chance to fit into the understanding more naturally.
 
g tsuji
Ranch Hand
Posts: 728
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I can direct you to the documentation, that may be helpful with the concrete cases here you can have adequate focus.

http://www.w3.org/TR/xmlschema-1/

2.6 Schema-Related Markup in Documents Being Validated

2.6.2 xsi:nil

XML Schema: Structures introduces a mechanism for signaling that an element should be accepted as ·valid· when it has no content despite a content type which does not require or even necessarily allow empty content. An element may be valid without content if it has the attribute xsi:nil with the value true. An element so labeled must be empty, but can carry attributes if permitted by the corresponding complex type.



The xs:nullable="true" in the schema document precisely allow the element in the document to be validated to acquire the schema instance attribute xsi:nil. If further it is set to true, empty content of that element will be treated as valid despite the content model of that element in the schema document.
 
A teeny tiny vulgar attempt to get you to buy our stuff
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!