XML schema hierarchical key constraint verfication

D

drmccoy

I'm trying to create a key that verify uniqueness hierarchically. Is
that even possible when using XML schema? So far I had no luck. XML
example:

<root>
<As>
<A id='1'>
<Bs>
<B id='1'/>
<B id='2'/>
<B id='3'/>
</Bs>
</A>
<A id='2'>
<Bs>
<B id='1'/>
<B id='2'/>
<B id='3'/>
</Bs>
</A>
</As>
</root>

B always has a parent A, therefore I'd like to have a key that
identifies a specific B that belongs to an A.
This construction fails to do what I want:

<xs:unique name="Unique">
<xs:selector xpath="As/A"/>
<xs:field xpath="@id"/>
<xs:field xpath="Bs/B/@id"/>
</xs:unique>

Any suggestions?
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top