Hi,
Is it possible in Xml to enfore the uniqueness of an element based on his
attribute value.
Say I have this schema :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.egemin.com/Epia/StringResources"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.egemin.com/Epia/StringResources"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="StrResources" type="StrResourcesType"/>
<xs:attribute name="LanguageAttr">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="nl"/>
<xs:enumeration value="nl-BE"/>
<xs:enumeration value="nl-NL/">
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:complexType name="StrResourcesType">
<xs:sequence>
<xs:element name="StrRes" type="StrResType" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="StrResType">
<xs:sequence>
<xs:element name="Tag" type="xs:ID"/>
<xs:element name="NeutrVal" type="StrValType"/>
<xs:element name="Localized" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Val" type="StrValType"/>
</xs:sequence>
<xs:attribute ref="LanguageAttr" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
And I have the following xml :
<?xml version="1.0" encoding="UTF-8"?>
<EPIA:StrResources xmlns:EPIA="http://www.egemin.com/Epia/StringResources"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.egemin.com/Epia/StringResources
StringResources.xsd">
<EPIA:StrRes>
<EPIA:Tag>
Egemin.EPIA.BaseContext.Context
</EPIA:Tag>
<EPIA:NeutrVal>Context</EPIA:NeutrVal>
<EPIA:Localized EPIA:LanguageAttr="nl"> <===
<EPIA:Val>Context</EPIA:Val>
</EPIA:Localized>
<EPIA:Localized EPIA:LanguageAttr="nl"> <===
<EPIA:Val>Contexte</EPIA:Val>
</EPIA:Localized>
</EPIA:StrRes>
</EPIA:StrResources>
How can I enfore that it is not allowed to have the attribute-val "nl" twice
in the same <EPIA:StrRes>-element ?