I am trying to write an XML schema. The specifics require me to validate a field so that it starts with a letter, followed by alphanumeric characters (e.g. Foo3x4 is valid, 3Foo or Foo3_ are not).
This is how I wrote it:
<xsd:simpleType name="nameType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="^[a-zA-z][a-zA-Z0-9]*$" />
</xsd:restriction>
</xsd:simpleType>
But if I try to validate a document that has as nameType the value H0, it gives me the following error (translated in English by me):
cvc-pattern-valid: The value "H0" is not valid as facet for the pattern "^[a-zA-z][a-zA-Z0-9]*$" for the type nameType
I can't get why. Using it on RegExr (/^[a-zA-z][a-zA-Z0-9]*$/gm
), it works. Am I missing something in the pattern specification?
One last detail. The validation error is given by the marshaller in the JAXB Java framework.