jeudi 7 novembre 2019

XML Schema Validation Pattern Restriction Error

I have the following files:

a.xml

<?xml version="1.0"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a.xsd">
  2
</e>

a.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>
</xs:schema>

and when validating i get:

Error:(4, 5) cvc-pattern-valid: Value ' 2 ' is not facet-valid with respect to pattern '[0-9]' for type '#AnonType_e'.

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire