• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

XML: Unique

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have an XML file with following structure

<Dteails>
< Person>
<Address>
<country>India</country>
</Address>
<Address>
<country>India</country>
</Address>
</person>
< Person>
<Address>
<country>India</country>
</Address>
<Address>
<country>India</country>
</Address>
</person>
</details



There can be more than One person
For each person ther can be more than one address

Th restriction to be imposed are

No two addresss block under a person can have same country

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

<Address>
<country>India</country>
</Address>
</person> This should not be allowed






But two diffrent persons can have same address in their country


< Person>
<Address>
<country>India</country>
</Address>
<Address>
<country>canada</country>
</Address>
</person>

< Person>
<Address>
<country>India</country>
</Address>
<Address>
<country>canada</country>
</Address>
</person>
This should be allowed


I used

<xs:unique name="country_Constraint1" msdata:ConstraintName="Constraint1" >
<xs:selector xpath=".//Address" />
<xs:field xpath="country" />

Then it was disallowing two address blocks with same countries for a person

But the problem is that it also dont allows two diffrent persons can having same address in their country . i want the case two to be allowed.How can this be done.

How the path is choses according to selector Path specified
 
Marshal
Posts: 28295
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So for each Person/Address you require non-duplicate country elements? Why not just say that in your schema then?
 
Abhi Venu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In schema I used

<xs:unique name="country_Constraint1" msdata:ConstraintName="Constraint1" >
<xs:selector xpath=".//Address" />
<xs:field xpath="country" />
But it wont allow dupliacte country name in all address fields..that is not specific to person/address
My requirement is limiting the scope of uniqueness under each person

please tell how can i specify that in schema
 
Paul Clapham
Marshal
Posts: 28295
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I know basically nothing about schema. So that's why I just made a general suggestion in my earlier post, rather than attempting to produce an actual correct schema. But you seem to have avoided paying attention to it. So let me have a go at changing your schema:

Now, that probably won't work either. I don't understand how the schema sets the context node for an XPath expression. But you're the one using schemas so perhaps you do. At any rate I leave you to fix it up.
 
Abhi Venu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all help Do any other have any idea
 
look! it's a bird! it's a plane! It's .... a teeny tiny ad
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic