Re: Empty content for Datatypes

Elena.

> <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