I would like to create a restriction for an XSD type to only allow an element of size 0 to 64, a dot, and another element of size 0 to 64. I tried this, but without success.
<xs:simpleType name="myString_Type">
<xs:restriction base="xs:string">
<xs:pattern value="^([a-zA-Z\-]){0-64}.$([a-zA-Z\-]){0-64}"/>
</xs:restriction>
</xs:simpleType>
Thanks.
^and$aren’t used for regex in XSD – it always matches from the start and end, as if they were there. Therefore, just omit them:And escape the
.(or use a character class as NullUserException said).From the XML Schema part 2: datatypes spec:
Their example is to use
A.*Znot^A.*Z$Because
^and$aren’t special characters, it will just try to match them in your xml document.It’s been said that unix is a collection of incompatible regular expression syntaxes, so by not following the unix standard, they are following the unix tradition.
You can test this example at: http://www.utilities-online.info/xsdvalidation/ (test instance from NullUserException)