Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate an element for unique value in multiple occuranes

 
Priti Shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this xml which allows multiple occurences of log file locations.

<some-element>
<log>log location 1</log>
<log>log location 2</log>
<log>log location 3</log>
<log>log location 4</log>
</some-element>

Now in my schema I want to check for max occurances 4 which I can do using 'maxOccur' attribute. But I also want to make sure that all 4 elements should have different values.
How can I do that ?

Thanks in advance.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch.
[Sorry about the delayed reply, I had to dust-off my XSD book to answer this.]

The construct you are looking for is xsd:unique.

Use something like -



You need to place this in the context in which you want to impose the uniqueness constraint. More homework to do.......

- m
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic