I am having a problem and i am unable to validate an XML document because of constraints. I have an XML Document that is like this:
<?xml version="1.0" encoding="UTF-8"?>
<organisation xmlns:xsi="http://ift.tt/ra1lAU" xsi:noNamespaceSchemaLocation="organisation.xsd">
<services>
<service num="direct">
<nom>Direction</nom>
<responsable num="100"/>
</service>
<service num="compta">
<nom>Comptabilite</nom>
<responsable num="101"/>
</service>
<service num="com">
<nom>Communication</nom>
</service>
</services>
<employes xmlns="http://www.employe.dz">
<employe id="101">
<nom>Krecker</nom>
<prenom>Ralf</prenom>
<activites>
<activite ref="compta"/>
</activites>
<details>
<age>29</age>
<sexe>Homme</sexe>
</details>
</employe>
<employe id="100">
<nom>Willey</nom>
<prenom>Joey</prenom>
<activites>
<activite ref="compta"/>
<activite ref="direct"/>
</activites>
</employe>
</employes>
</organisation>
This is my XML Schema Code: employes.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://ift.tt/tphNwY" elementFormDefault="qualified"
targetNamespace="http://www.employe.dz" xmlns = "http://www.employe.dz">
<xs:element name="employes">
<xs:complexType>
<xs:sequence>
<xs:element name="employe" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="prenom" type="xs:string"/>
<xs:element name="activites">
<xs:complexType>
<xs:sequence>
<xs:element name="activite" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ref" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="age" type="xs:nonNegativeInteger"/>
<xs:element name="sexe" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="cleEmploye">
<xs:selector xpath="employe"/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
</xs:schema>
organisation.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://ift.tt/tphNwY" xmlns:p = "http://www.employe.dz">
<xs:import namespace="http://www.employe.dz" schemaLocation="employes.xsd"/>
<xs:element name="services">
<xs:complexType>
<xs:sequence>
<xs:element name="service" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="nom" type="xs:string"/>
<xs:element name="responsable" minOccurs="0">
<xs:complexType>
<xs:attribute name="num" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="num" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="cleService">
<xs:selector xpath="service"/>
<xs:field xpath="@num"/>
</xs:key>
</xs:element>
<xs:element name="organisation">
<xs:complexType>
<xs:sequence>
<xs:element ref="services"/>
<xs:element ref="p:employes"/>
</xs:sequence>
</xs:complexType>
<xs:keyref refer="p:cleEmploye" name="foreignKey1">
<xs:selector xpath="services/service/responsable"/>
<xs:field xpath="@num"/>
</xs:keyref>
<xs:keyref refer="cleService" name="foreignKey2">
<xs:selector xpath="p:employes/p:employe/p:activites/p:activite"/>
<xs:field xpath="@ref"/>
</xs:keyref>
</xs:element>
</xs:schema>
i use oXygen version 16.1. when i validate the document, i have the error below:
Gravité: error Description: cvc-identity-constraint.4.3: Key 'foreignKey1' with value '100' not found for identity constraint of element 'organisation'. Emplacement de début: 37:16 URL: http://ift.tt/1CQwu1v
No comments:
Post a Comment