I would appreciate help on this one.
How do I create a type which has two unique attributes. I know how to make one of the attributes unique but don't know for two. The two attributes have to be independently unique i.e. each one of them must be unique within the context of the current node. It follows that the combination of the two will be unique. Take the element node below for example:
Code:
<computer>
<part name="chasis" number="234">
<description>DELL chasis</description>
<connected>false</connected>
</part>
<part name="chasis" number="233">
<description>DELL chasis</description>
<connected>false</connected>
</part>
</computer>
I have created the schema part of this as follows so that the "number" attribute is unique. I want to do the same for the "chasis" attribute but I get errors if I repeat what I did for the "chasis". I can see why I get errors as it is not valid XML because I end up having two element nodes which are the same
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="computer">
<xs:complexType>
<xs:sequence>
<xs:element name="part" type="partType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="part">
<xs:selector xpath="part"/>
<xs:field xpath="@number"/>
</xs:unique>
</xs:element>
<xs:complexType name="partType">
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="connected" type="xs:boolean"/>
</xs:sequence>
<xs:attribute name="name" type="xs:token" use="required"/>
<xs:attribute name="number" type="xs:positiveInteger" use="required"/>
</xs:complexType>
</xs:schema>
Note that I am not looking for this.
Code:
<xs:unique name="part">
<xs:selector xpath="part"/>
<xs:field xpath="@number"/>
<xs:field xpath="@name"/>
</xs:unique>
Thanks in advance