I have this xml file:
<objects> <object name="ID1" /> <object name="ID2" /> <object name="ID2" color="green" /> <object name="ID3" color="green" /> <objects>
I would like to test this on the XSD schema, so the combination between name and color unique in the document.
The problem is that if I use:
<xs:unique name="UniqueObjectNameColor"> <xs:selector xpath="./object" /> <xs:field xpath="@name" /> <xs:field xpath="@color" /> </xs:unique>
... the rule ignores object elements without the additional color attribute. The following correct statement is correct, while it should not.
<object name="ID2" /> <object name="ID2" />
Can you tell me how to specify a rule that applies unique combinations of name and color , and when the color attribute is missing from the object element, it checks the name ?
xml unique xsd
Vitor
source share