I want write an XSD to restrict the content of valid XML elements of type xsd:token such that at validation they would indistinguishable from the same content wrapped in xsd:string.
I.e. they do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, begin or end with a space (#x20) character, and do not include a sequence of two or more adjacent space characters.
I think the regular expression to use is this:
\S+( \S+)*
(some non-whitespace, optional [single spaces next to one or more non-whitespaces], including always non-whitespace to close out)
This works with various regex testing tools but I can't seem to check it using oXygen XML Editor; double spaces, leading and trailing spaces, tabs, and line breaks in the strings seem to allow the XML instance to still pass validation.
Here's the XSD implementation:
<xs:simpleType name="Tokenized500Type">
<xs:restriction base="xs:token">
<xs:maxLength value="500"/>
<xs:minLength value="1"/>
<xs:pattern value="\S+( \S+)*"/>
</xs:restriction>
</xs:simpleType>
Is there some feature of
- XML
or
- XSD
or
- oXygen XML Editor
that prevents this working?