[XSD] Plusieur keyref dans un element.
Bonjours,
J'ai un souci avec l'utilisation des xs:key et xs:keyref dans les schémas(*.xsd) :roll:
Je n'arrive pas à trouver comment faire pour qu'un élément puisse posséder plusieurs référence de clé (xs:keyref).
Voici un petit exemple pour illustre mon problème :
test.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?xml version="1.0" encoding="UTF-8"?>
<ecole xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<!-- liste des profs -->
<prof>
<id>A</id>
<nom>Mr A</nom>
</prof>
<prof>
<id>B</id>
<nom>Mr B</nom>
</prof>
<!-- liste des matieres, une matiere peu faire referance a plusieur prof -->
<matiere>
<nom>Francais</nom>
<ref-prof>A</ref-prof>
<ref-prof>B</ref-prof>
</matiere>
</ecole> |
test.xsd :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ecole" type="TypeEcole">
<xs:key name="id.prof">
<xs:selector xpath="prof"></xs:selector>
<xs:field xpath="id"></xs:field>
</xs:key>
<xs:keyref refer="id.prof" name="ref.prof">
<xs:selector xpath="matiere"></xs:selector>
<xs:field xpath="ref-prof"></xs:field>
</xs:keyref>
</xs:element>
<xs:complexType name="TypeEcole">
<xs:sequence>
<xs:element name="prof" type="TypeProf" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="matiere" type="TypeMatiere" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TypeProf">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="nom" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TypeMatiere">
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="ref-prof" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema> |
Le problème avec cette exemple, c'est que la validation me dit :
Citation:
SystemID: /home/ekinoks/Desktop/XML/test.xml
Endroit: 17:31
Description: [Xerces] cvc-identity-constraint.3: Field "./ref-prof" of identity constraint "ref.prof" matches more than one value within the scope of its selector; fields must match unique values.
URL:
http://www.w3.org/TR/xmlschema-1/#cv...ity-constraint
Apparemment il ne veux pas que "matiere" possède plusieurs "ref-prof"
Quelqu'un serait il pour quoi ? et comment contourner le probleme ?
Merci pour votre aide.