[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

null vs empty in XML Schemas

  • From: Roger Costello <costello@m...>
  • To: xml-dev@i...
  • Date: Sun, 02 Jan 2000 07:58:30 -0500

null xml
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.