
October 14th, 2004, 07:08 AM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
xs:unique question when writing XML Schema
Hi,
I am writing an XML Schema document and am stuck when defining the document's complex types. I wish to define a complex type containing 0-many elements which must be unique by name. Below is an example of what I'm trying to achieve:
Code:
...
<xs:complexType name="typeA">
<xs:sequence>
<xs:element name="parameter" type="jparameter" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:unique name="parameter-name-uniqueness">
<xs:selector xpath="parameter"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:complexType>
...
As you can see, I wish to keep all 'jparameter' elements unique within the 'typeA' type, which is why the xs:unique tag is inside typeA's tag. It appears however that xs:unique tags can only appear inside xs:element tags, which would prevent me from defining the above common type to be reused.
Can anyone offer a workaround, perhaps my schema layout is flawed?
Cheers
|