C
cedric.louyot
Hi,
I've written a schema that looks like :
<xs:schema>
<xs:complexType name="myType">
<xs:sequence>
<xs:element name="e1" type="T1" maxOccurs="unbounded"/>
<xs:element name="e2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T1">
<xs:sequence>
<xs:element name="e3" type="T3" maxOccurs="unbounded"/>
<xs:element name="e4" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T3">
<xs:sequence>
<xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
<xs:element name="adress" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="myElement" type="myType">
<xs:unique name="uniqueName>
<xs:selector xpath="./e1/e3"/>
<xs:field xpath="name"/>
</xs:unique>
</xs:element>
</xs:schema>
The <xs:unique/> element garantees there is only one element "./e1/e3"
in my xml file that has a given name. This prevents me from having 2
elements with the same name in 2 different e1 elements because my
<xs:unique/> element is in the scope of "myElement". I would like to
be allowed to name two element e3 with the same name providing they do
not have the same e1 ancestor. Therefore I have to define my
<xs:unique/> element in the scope of "myElement/e1" instead of
"myElement".
How do I do that given that I want to keep defining all my complex
types before defining the "myElement" element ? I would like to avoid
defining more than one <xs:element/> element.
Thanks,
Cédric
I've written a schema that looks like :
<xs:schema>
<xs:complexType name="myType">
<xs:sequence>
<xs:element name="e1" type="T1" maxOccurs="unbounded"/>
<xs:element name="e2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T1">
<xs:sequence>
<xs:element name="e3" type="T3" maxOccurs="unbounded"/>
<xs:element name="e4" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="T3">
<xs:sequence>
<xs:element name="name" type="xs:string" maxOccurs="unbounded"/>
<xs:element name="adress" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="myElement" type="myType">
<xs:unique name="uniqueName>
<xs:selector xpath="./e1/e3"/>
<xs:field xpath="name"/>
</xs:unique>
</xs:element>
</xs:schema>
The <xs:unique/> element garantees there is only one element "./e1/e3"
in my xml file that has a given name. This prevents me from having 2
elements with the same name in 2 different e1 elements because my
<xs:unique/> element is in the scope of "myElement". I would like to
be allowed to name two element e3 with the same name providing they do
not have the same e1 ancestor. Therefore I have to define my
<xs:unique/> element in the scope of "myElement/e1" instead of
"myElement".
How do I do that given that I want to keep defining all my complex
types before defining the "myElement" element ? I would like to avoid
defining more than one <xs:element/> element.
Thanks,
Cédric