Question

I have an xml file with the following line to it.

<asin ISBN="1234567890 1234567890123" code="aB1234Av">

i want to write a restriction on the ISBN with the given format. By that i mean 10 digit first then a space and then 13 digit. I tried a regex but its not working. Here's my xsd.

<xsd:schema  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="asin">

        <xsd:attribute name="ISBN">

            <xsd:simpleType>

                <xsd:restriction base="xsd:integer">

                    <xsd:pattern value="[0-9]{10}[^ ][0-9]{13}"/>

                </xsd:restriction>

            </xsd:simpleType>

        </xsd:attribute>

    </xsd:element>

</xsd:schema>

Can someone help me solve this please.

Was it helpful?

Solution

[^ ] is a negated character class that says anything but a space, try it with [ ], , or \s.

<xsd:pattern value="[0-9]{10}[ ][0-9]{13}"/>

Demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top