 |
 |
 |
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@w...
> [mailto:xmlschema-dev-request@w...] On Behalf Of Chris Drozdowski
> Sent: 11 December 2004 15:39
> To: xmlschema-dev@w...
> 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@e...
>
>
>
>
From mike@s... Sat Dec 11 23:38:44 2004
Received: from bart.w3.org ([128.30.52.40])
by frink.w3.org with esmtp
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |