Numeric ID type in XML Schema
I need to define an ID type with a given pattern using XML schema. What I am so far is:
<xs:simpleType name="myid">
<xs:restriction base="xs:ID">
<xs:pattern value="[A-Za-z0-9_-]+"/>
</xs:restriction>
</xs:simpleType>
This works, except it is <myid>00123_45678<myid>
not checked , for example . Apparently the base type xs: ID requires its own values ββfor XML-unqualified names (xs: NCName). In particular, identifiers may not start with numbers.
Is there an alternative way of defining the document ID using XML Schema that allows a numeric first character?
source to share
Derive your type from xsd: string or xsd: token or xsd: NMTOKEN, not an identifier. The xsd: ID type introduces XML naming rules and therefore requires the value to begin with the namestart character.
Restore the uniqueness constraint by adding an xs: unique declaration to the corresponding parent element.
source to share