Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD attribute cannot equal value?

Tags:

xml

schema

xsd

How can I restrict an attribute to not allow a particular value?

For instance, I have an <xs:key/> on an Id attribute of an element, but some yahoo has gone and thrown a magic number in there so now I cannot allow 3, but 1, 2, and 5 are perfectly acceptable.

like image 355
Lance Avatar asked Dec 01 '25 15:12

Lance


1 Answers

Have you tried having a look at the restriction tag link text, the code below, it should give you a tag called Id which only allows integers that doesn't start with a 3

<xs:key name="Id">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
            <xs:pattern value="[^3]\d*"/>
       </xs:restriction>
  </xs:simpleType>
</xs:key>
like image 199
Meberem Avatar answered Dec 03 '25 08:12

Meberem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!