MSXML schema validation on type "token"

L

linkspeed

Hi, I tried following element definition in MSXML 4.0
<xsd:element name="Identifier">
<xsd:simpleType>
<xsd:restriction base="xsd:token">
<xsd:pattern value=".*"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

It can validate XML text like: <Identifier>abbbb</Identifier>
But not :
<Identifier>
abbbb</Identifier>

and
<Identifier>abbbb
</Identifier>

and
<Identifier>
abbbb
</Identifier>

Isn't token a white space collapsed string?

Cheers
Linkspeed
 
M

Martin Boehm

Hi, I tried following element definition in MSXML 4.0
<xsd:element name="Identifier">
<xsd:simpleType>
<xsd:restriction base="xsd:token">
<xsd:pattern value=".*"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

What sense does this kind of pattern have?
It can validate XML text like: <Identifier>abbbb</Identifier>
But not :
<Identifier>
abbbb</Identifier>

Sure, not at last because your pattern does not allow newlines. A token
cannot contain newlines, either.
Isn't token a white space collapsed string?

It maybe *has to be* a string containing no white spaces, but it is not
converted to one as the schema is used for validation. The schema must
match the XML *as is*, not as *would be*. If you used base="xsd:string"
as restiction base it also would not have worked out (because of the
pattern).

Martin
 
R

Richard Tobin

Martin Boehm said:
Sure, not at last because your pattern does not allow newlines. A token
cannot contain newlines, either.

But the token type has a whiteSpace facet with value "collapse", so
the newline should be turned into a space and then removed *before*
testing for validity.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top