Home > Enterprise >  XML schema pattern, range of signs
XML schema pattern, range of signs

Time:11-20

How to define an xsd pattern, where you have a range of amount of signs? Let's say i want 1 upper-case letter and between 1 to 20 lower-case letters. I came up with something like this, but it doesn't work.

<xsd:simpleType name="NameType">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="[A-Z][a-z]{1-20}"/>
        </xsd:restriction>
</xsd:simpleType>

CodePudding user response:

Use a , instead of a - to specify the range:

<xsd:pattern value="[A-Z][a-z]{1,20}"/>.

Then your code will work as expected.

  • Related