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

RE: [xmlschema-dev] <none>

From: Michael Kay <mike@saxonica.com>
Date: Sat, 11 Dec 2004 18:58:35 -0000
To: "'Chris Drozdowski'" <c.d@earthlink.net>, <xmlschema-dev@w3.org>
Message-Id: <E1CdCRz-0005SK-00@ukmail1.eechost.net>

xs:token is defined in XML Schema Part 2 thusly:

[Definition:]   token represents tokenized strings. The .value space. of
token is the set of strings that do not contain the carriage return (#xD),
line feed (#xA) nor tab (#x9) characters, that have no leading or trailing
spaces (#x20) and that have no internal sequences of two or more spaces. The
.lexical space. of token is the set of strings that do not contain the
carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have
no leading or trailing spaces (#x20) and that have no internal sequences of
two or more spaces. The .base type. of token is normalizedString.

According to my reading, the zero-length string is therefore a valid
instance of xs:token. Which validator are you using?

Incidentally, xs:token is a gross misnomer; many people use the type
imagining wrongly that tokens cannot contain internal spaces. Perversely,
despite the plethora of data types provided in XML Schema, there isn't one
that allows any string of non-whitespace characters.

(You also need to be aware that the lexical space describes not the value as
written in the source document, but rather the value produced after
whitespace normalization. Since the whitespace handling for xs:token is
"collapse", the restrictions on leading, trailing, and internal whitespace
will be satisfied automatically.)

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Chris Drozdowski
> Sent: 11 December 2004 15:39
> To: xmlschema-dev@w3.org
> Subject: [xmlschema-dev] <none>
> 
> Hello,
> 
> Can an element in an XML document be empty if it is defined 
> as a token 
> type in the schema (see example below)?
> My validator will accept empty elements if the type is string but 
> chokes on token.
> 
> <?xml version="1.0"?>
> <people>
>      <person>
>          <fname>John</fname>
>          <mname/>
>          <lname>John</lname>
>      </person>
> </people>
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 
> <xs:element name="people">
>      <xs:complexType>
>          <xs:sequence>
>              <xs:element name="person" type="persontype" 
> minOccurs="0" 
> maxOccurs="unbounded"/>
>          </xs:sequence>
>      </xs:complexType>
> </xs:element>
> 
> <xs:complexType name="persontype">
>      <xs:sequence>
>          <xs:element name="fname" type="xs:token"/>
>          <xs:element name="mfname" type="xs:token"/>
>          <xs:element name="lfname" type="xs:token"/>
>      </xs:sequence>
> </xs:complexType>
> 
> </xs:schema>
> 
> 
> Thanks,
> 
> Chris Drozdowski
> 
> c.d@earthlink.net
> 
> 
> 
> 
Received on Saturday, 11 December 2004 18:58:39 GMT

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