This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML-unique Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML-unique" Watch "XML-unique" New topic
Author

XML-unique

Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73
<Address>
<country>India</country>
</Address>

<Address>
<country>India</country>
</Address>

I need to create an XML with following restriction .It can have multiple address elements; inside each address there will be a element country

The country name under each Address block should be unique. it should not get repeated i.e No two address Block can have same country field

I used <xs:unique name="Country_name">
<xs:selector xpath="Address /country">
<xs:field xpath="." />
</xs:unique>

but it will impose restriction only on a Address block and not in two different address blocks
















A table, a chair, a bowl of fruit and a violin; what else does a man need to be happy?:Einstein
Venkata Kumar
Ranch Hand

Joined: Apr 16, 2008
Posts: 110

<xs:selector xpath="Address /country">
<xs:field xpath="." />


You may try this


SCJP 5.0, SCWCD 5, preparing for SCDJWS
 
jQuery in Action, 2nd edition
 
subject: XML-unique
 
Similar Threads
XML schema unique validation is not working
Search for a specific ID
Unique constrain using XML Schema
tag-value should be unique ...
XML: Unique