I try to create an xsd schame for this xml file :
<?xml version="1.0"?>
<Listelocataires xmlns:xsi="http://ift.tt/ra1lAU" xsi:noNamespaceSchemaLocation="locataires.xsd">
<NoImmeuble>221B</NoImmeuble>
<etage n="1">
<appartement cote="gauche">
<nom>Watson</nom>
</appartement>
<appartement cote="droit">
<nom>Holmes</nom>
<telephone>020 7465 4321></telephone>
</appartement>
</etage>
<etage n="0">
<appartement cote="droit">
<nom>Hudson</nom>
<telephone>020 7465 4321></telephone>
</appartement>
</etage>
</Listelocataires>
I try to create an custom type for the validation of the telephone number, but it didn't accept my answer, here is my xsd schema :
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://ift.tt/tphNwY">
<xsd:element name="Listelocataires">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="NoImmeuble" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="etage" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="NoImmeuble" type="xsd:string" />
<xsd:element name="etage">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="appartement" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="n" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="appartement">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="nom" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="telephone" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="cote" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="nom" type="xsd:string" />
<xsd:element name="telephone" type="typeTelephone"/>
<xsd:simpleType name="typeTelephone">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3} \d{4} \d{4}" />
</xsd:restriction>
</xsd:simpleType>
Xmllint give me those errors :
locataires.xml:10: element telephone: Schemas validity error : Element 'telephone': [facet 'pattern'] The value 'à020 7465 4321>' is not accepted by the pattern 'à\d{3} \d{4} \d{4}'. locataires.xml:10: element telephone: Schemas validity error : Element 'telephone': 'à020 7465 4321>' is not a valid value of the atomic type 'typeTelephone'. locataires.xml:16: element telephone: Schemas validity error : Element 'telephone': [facet 'pattern'] The value 'à020 7465 4321>' is not accepted by the pattern 'à\d{3} \d{4} \d{4}'. locataires.xml:16: element telephone: Schemas validity error : Element 'telephone': 'à020 7465 4321>' is not a valid value of the atomic type 'typeTelephone'.
I don't understand why, if you see, please help me, Best regards, Zed13
No comments:
Post a Comment