Bonjour,
J'essaie d'étendre un élément XML tout en ajoutant des restrictions au niveau de certains attritbus. Mais je perds la définition des sous-éléments.
Par exemple, j'ia le schéma suivant :
<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:tns="http://www.example.org/NewXMLSchema" elementFormDefault="qualified" targetNamespace="http://www.example.org/NewXMLSchema" xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="Address">
<attribute name="postalCode" use="optional" type="string" />
<attribute name="city" use="optional" type="string" />
</complexType>
<complexType name="BasePerson" mixed="true">
<sequence>
<element name="Address" type="tns:Address" minOccurs="1" />
</sequence>
<attribute name="firstName" type="string" />
<attribute name="lastName" type="string" />
<attribute name="middleName" type="string" use="optional" />
</complexType>
<complexType name="Person">
<complexContent mixed="true">
<restriction base="tns:BasePerson">
<attribute name="middleName" use="prohibited" />
</restriction>
</complexContent>
</complexType>
<element name="person" type="tns:Person" />
</schema> |
J'ai BasePerson qui sert de base, mais j'utilise Person en pratique. Ce dernier élément supprime l'attribut middleName. Par contre, pas moyen de lui ajouter une adresse !
Mon XML de test :
<?xml version="1.0" encoding="utf-8"?>
<tns:person xmlns:tns="http://www.example.org/NewXMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/NewXMLSchema NewXMLSchema.xsd"
firstName="string" lastName="string">
</tns:person>
|
Avec l'élément Address, ça ne valide plus !
<?xml version="1.0" encoding="utf-8"?>
<tns:person xmlns:tns="http://www.example.org/NewXMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/NewXMLSchema NewXMLSchema.xsd"
firstName="string" lastName="string">
<Address />
</tns:person>
|
Comment puis-je résoudre ce problème ?
---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi