[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] null vs empty in XML Schemas
Hi Folks, I have two questions: 1. What is the difference between null and empty? 2. How is nullable/null used? My understanding of the difference between null and empty is: - If an element is declared to be of type empty then in the XML instance document the content of that element is a string of length zero. - If an element is declared with nullable="true" then in the XML instance document if the element has xsi:null="true" then this element has undefined content. Is this a correct understanding of the difference between empty and null? Below is my understanding of how nullable/null is to be used: Here is an example XML Schema snippet declaring an element (middle) with nullable="true": <element name="PersonName"> <type> <element name="forname" type="NMTOKEN"/> <element name="middle" type="NMTOKEN" nullable="true"/> <element name="surname" type="NMTOKEN"/> </type> </element> Here is an example XML instance document conforming to the above schema snippet, where the middle element has been set to a null value: <PersonName> <forename>John</forename> <middle xsi:null="true"/> <surname>Doe</surname> </PersonName> Thus, middle may contain a NMTOKEN value, or it may indicate that there is no defined value. Is this the correct usage of nullable/null? My reason for asking is because in the XML Schema spec, after nullable/null is discussed there is an Issue section stating: "Issue (nullRequiresEmpty): Is it a precondition for being nullable that the element's contentType allow no content? If not, then more needs to be said above, if so, this needs to be spelled out." This isn't consistent with the above example. I thought that an element declared with nullable="true" can have a value in the instance document when a value is available. When no value is available then we can indicate this in the instance document by setting xsi:null="true". This Issue seems to say that elements declared with nullabe="true" can never have a value in the instance document. Thus, the middle element can never have a value. Wherein lies the truth? /Roger xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1 To unsubscribe, mailto:majordomo@i... the following message; unsubscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|