Re: xsi:type Usage

On Mon, 2005-12-05 at 15:33, Tobin M Clough wrote:

> Hello,

> I think this is a very simple question, but I can't seem to find any
> documentation on it.  Is this a legal application of the xsi:type
> construct?:

> <isOkay xsi:type="xsd:boolean"/>

> With validation turned off, it seems like this would be a reasonable
> representation of no value (null) for a data item that is either
> true, false, or empty.

If there is no schema, or if 'isOkay' is declared with type
xsd:anyType, xsd:anySimpleType (or, in XML Schema 1.1,
xsd:anyAtomicType), then it's certainly legal to supply an xsi:type
attribute with the value xsd:boolean (assuming that xsd is properly
bound as a namespace prefix in this context).

On the other hand, since the empty string is not a member of the
lexical space of xsd:boolean, the 'isOkay' element shown above will
not be valid. 

If the element 'isOkay' is declared nillable, then

  <isOkay xsi:type="xsd:boolean" xsi:nil="true"/> 

would be valid.  But I believe you are talking about using xsi:type
with undeclared elements; for those, empty elements will be valid only
when the empty string is a member of the relevant lexical space.

Hmm.  I notice that you talk about using this "with validation turned
off".  Under those circumstances, of course, it hardly matters whether
the element would be valid or not if it *were* validated. 

I hope this helps.

-C. M. Sperberg-McQueen
 World Wide Web Consortium

Received on Thursday, 8 December 2005 01:59:11 UTC