mardi 15 mai 2018

XSD regex expression validation

i have the following xsd schema

 <?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="virement">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="numero" type="xs:string" />
        <xs:element name="date" type="xs:unsignedLong" />
        <xs:element name="titulaire">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="nom" type="xs:string" />
              <xs:element name="banque" type="xs:string" />
              <xs:element name="compte" type="xs:string" />
               <xs:element name="test">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                        <xs:pattern value="\d{3}-[A-Z]{2}|\d{7}"/>
                        </xs:restriction>
                    </xs:simpleType>
            </xs:element>  
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="montant" type="xs:unsignedInt" />
        <xs:element name="motif" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

But i tried the validation online and it's not working with that example

<?xml version="1.0" encoding="utf-8"?>
<virement>
    <numero>THRW0002DZDBNA4256DZD201802041053</numero>
    <date>201802041053</date>
    <titulaire>
       <nom>Nom Bidon</nom>
       <banque>THW</banque>
       <compte>THW152345DZD</compte>
       <test>FOOB45-9876</test>
    </titulaire>
    <montant>300000</montant>
    <motif>Pret pour projet immobilier</motif>
</virement>

this is the error i'm getting Error

i don't know why, but when i try the validation in regex validator , the string matchs the pattern , but when i try with the xsd Schema i get this error !!

Aucun commentaire:

Enregistrer un commentaire