unique attribute value

K

kanpeter

Hi,

How can I declare the xsd such that an element Fare will have an
attribute of name "type" and each value of "type" can occur at most
once?



<Fare type="faretype1"/>
<Fare type="faretype2"/>

is valid in XML but not

<Fare type="faretype1"/>
<Fare type="faretype1"/>
 
M

Martin Honnen

kanpeter said:
How can I declare the xsd such that an element Fare will have an
attribute of name "type" and each value of "type" can occur at most
once?



<Fare type="faretype1"/>
<Fare type="faretype2"/>

is valid in XML but not

<Fare type="faretype1"/>
<Fare type="faretype1"/>


In the definition of the parent element of those "Fare" elements use
<xs:unique name="unique-fare-type">
<xs:selector xpath="Fare"/>
<xs:field xpath="@type"/>
</xs:unique>
See http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top