A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
XML and Related Technologies
validate an element for unique value in multiple occuranes
Joined: May 10, 2005
May 10, 2005 11:51:00
I have this xml which allows multiple occurences of log file locations.
<log>log location 1</log>
<log>log location 2</log>
<log>log location 3</log>
<log>log location 4</log>
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.
Joined: Jun 03, 2000
May 11, 2005 19:48:00
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
Use something like -
<xsd:unique name="SomeUniqueValue"> <xsd:selector xpath="*/log"/> <xsd:field xpath="."/> </xsd:unique>
You need to place this in the context in which you want to impose the uniqueness constraint. More homework to do.......
Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: validate an element for unique value in multiple occuranes
Can we use multiple Controllers in a single web-application?
Castor: Mapping Element not included in Java Class
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015