W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

Re: value of a NULL element

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 5 Dec 2001 13:14:54 +0000
Message-ID: <18382728397.20011205131454@jenitennison.com>
To: "maddy pawar" <madhuvanti@hotmail.com>
CC: xmlschema-dev@w3.org
Hi Maddy,

> If i try to obtain the contents of an empty element, what is the
> return value i should expect? Is is "NULL"?

It depends on what you're using to obtain the contents of the empty
element. If you have:

  <foo />

then in XPath, the foo element has no child nodes and has a string
value of ''. In DOM, the foo element has no child nodes.

As far as an XML Schema validator is concerned the foo element has no
content and if you've declared it as being of type string it has the
value of an empty string; if you've declared it as being as type
decimal it's not a valid element (because it doesn't have a number as
its value) - its lexical value is an empty string.

If you have:

  <foo xsi:nil="true" />

Then the value of the foo element is the same as above, but it is
also labelled as being a nil value.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 5 December 2001 09:50:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT