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

Re: Empty content for Datatypes

From: Jeff Rafter <jeffrafter@definedweb.com>
Date: Wed, 14 Mar 2001 15:00:16 -0800
Message-ID: <034901c0acda$89dd65d0$f181fea9@lazarus>
To: "Elena Litani" <hlitani@jtcsv.com>
Cc: <xmlschema-dev@w3.org>

> <element name="age" type="positiveInteger"/>
> Will <age/> or <age></age> in instance XML document be valid?

No.  These values are not actually "null" wrt to the explicit use of
xsi:null="true" they simply have empty content and therefore do not match
the positiveInteger simpleType.

> Should I declare an element as "nillable" so that empty content is
> allowed?

I think you meant "nullable".  Yes this should give you what you want--
assuming you place the attribute xsi:null="true" in your element.  Though
there is currently a request for feedback regarding "null".  The only
wording I could find for this was:

"If {nullable} is true, then an element may also be valid if it carries the
namespace qualified attribute with [local name] null from namespace
http://www.w3.org/2000/10/XMLSchema-instance and value true (see xsi:null
(2.6.2)) even if it has no text or element content despite a {content type}
which would otherwise require content. Formal details of element validation
are described in Element Locally Valid (Element) (3.3)."

So even with 'nullable="true"' the following is true:

<age/> = invalid
<age></age> = invalid
<age xsi:null="true"/> = valid
<age xsi:null="true"></age> = valid
<age xsi:null="true">10</age> = invalid
<age>10</age> = valid

Good luck,
Jeff Rafter
Defined Systems
Received on Wednesday, 14 March 2001 18:00:47 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:51 UTC