IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topicStart Poll

En ligne · [ Standard ] · Linéaire+

> [xml] Problème De Schema Xsd

PoP
post 14/12/2005 11:58
Message #1


ragondin interstellaire
*****

Groupe : Membres
Messages : 3,059
Inscrit le : 16/05/2002 23:00
Lieu : DTC, au fond à gauche
Membre no. 8



Je suis en train de faire un schema XSD de validation d'un fichier XML. Mon fichier XML doit avoir cette tronche là:

CODE

     <request type="addData">
           <session id="(string)"/>
           <block tempId="(string)">
                 <right clientId="(string)" value="(string)"/>
                 <desc crypt="(boolean) checksum="(string)">(bytes)</desc>
                 <data crypt="(boolean)" checksum="(string)">(bytes)</data>
           </block>
     </request>


Je cherche donc à faire un schéma XSD pour imposer ce formalisme. Voici ce que j'ai pour l'instant:

CODE

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

     <!-- Definition du type datacontainer -->
     <xs:complexType name="datacontainer">
           <xs:complexContent>
                 <xs:extension base="xs:byte">
                       <xs:sequence>
                             <xs:attribute name="crypt" type="xs:boolean" use="optional" />
                             <xs:attribute name="checksum" type="xs:string" use="optional" />
                       </xs:sequence>
                 </xs:extension>
           </xs:complexContent>
     </xs:complexType>

     <!-- Definition of the session node -->
     <xs:element name="session">
           <xs:complexType>
                 <xs:attribute name="id" type="xs:string" use="required" />
           </xs:complexType>
     </xs:element>

     <!-- definition of the block node -->
     <xs:element name="block">
           <xs:complexType>
                 <xs:sequence minOccurs="1" maxOccurs="1">
                       <xs:element ref="right" minOccurs="0" maxOccurs="unbounded" />
                       <xs:element ref="desc" minOccurs="0" maxOccurs="1" type="datacontainer" />
                       <xs:element ref="data" minOccurs="0" maxOccurs="1" type="datacontainer" />
                 </xs:sequence>
                 <xs:attribute name="tempId" type="xs:string" use="required" />
           </xs:complexType>
     </xs:element>

     <!-- definition of the right node -->
     <xs:element name="right">
           <xs:complexType>
                 <xs:attribute name="clientId" type="xs:string" use="optional" />
                 <xs:attribute name="gfcId" type="xs:string" use="optional" />
                 <xs:attribute name="value" type="xs:string" fixed="[0|1]{5,5}" use="required" />
           </xs:complexType>
     </xs:element>

     <!-- Definition of the request node -->
     <xs:element name="request">
           <xs:complexType>
                 <xs:sequence minOccurs="1" maxOccurs="1">
                       <xs:element ref="session" minOccurs="1" maxOccurs="1" />
                       <xs:element ref="right" minOccurs="0" maxOccurs="unbounded" />
                       <xs:element ref="block" minOccurs="0" maxOccurs="unbounded" />
                 </xs:sequence>
                 <xs:attribute name="type" type="xs:string" use="required" fixed="addData"/>
           </xs:complexType>
     </xs:element>

</xs:schema>


Mais ça passe pô. <xs:extension base="xs:byte"> me jette Complex Type Definition Representation Error for type 'datacontainer'. When <complexContent> is used, the base type must be a complexType. 'byte' is a simpleType.

Grumpf...comment je fais moi alors?


--------------------
PoP
"Consommez malin, consommez du ragondin!"
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Sha
post 14/12/2005 15:34
Message #2


Cartographe
****

Groupe : Membres
Messages : 2,065
Inscrit le : 16/05/2002 23:00
Lieu : Toulouse
Membre no. 5



J'y connais rien en xml, mais une idée niaise m'est venue : encapsuler ton type simple dans une structure de données idoine.

Ce message a été modifié par Sha - 14/12/2005 17:51.


--------------------
"[I reject] politically-oriented thinking as essentially a hopeless waste of intellectual effort." - John Nash.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicTopic OptionsStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :
 

Version bas débit Nous sommes le : : 25/04/2024 10:45