I need to enforce all caps or numbers or spaces but disallow leading
or trailing spaces. If I could dissallow double spaces that would be
a bonus. This is what I have so far:
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
<xs:pattern value="([A-Z0-9 -])*"/>
</xs:restriction>
</xs:simpleType>
You need to prohibit the leading and trailing spaces separately by
specifying that the first character must be a letter or digit; followed
by any mix of letters, digits, spaces, or hyphens; followed by a letter
or digit. The ^ binds to the start of the expression and the $ binds to
the end of the expression:
"^[A-Z0-9][A-Z0-9\ \-]*[A-Z0-9]$"
That's normal RE syntax. I don't know if that is acceptable within the
XSD, and I'm uncertain about how to prohibit a double-space.
///Peter
--
XML FAQ: http://xml.silmaril.ie/
Actually <xs:whiteSpace value="collapse"/> should eliminate any leading,
trailing and multiple spaces before checking the pattern. That would
prevent invalidation of these spaces.
--
Mayeul