Verifying the contents with key, keyref

koch.henning

Usenet Archive
Joined
Jun 15, 2006
Messages
1
Reaction score
0
Hello,

I have some sort of problem with verifying the contents of my xml-document. I have a xml-scheme like this...

<xs:complexType name="abcType">
<xs:sequence>
<xs:element name="elementA" type="elementAType"/>
<xs:element name="elementB" type="elementBType"/>
<xs:element name="elementC" type="elementCType"/>
</xs:sequence>
<xs:attribute name="ID" type="xs:string"/>
</xs:complexType>

This abcType has an Attribute ID. And each of these elementA,B,C-Types has Subelements. Now I want to verify some things in the xml-document with the key-, keyref-Elements. I want to get only the some special sub-elements of elementBType.

I tried something like this:

<xs:element name="abc" type="abcType">

<xs:key name="IDKey">
<xs:selector xpath=".//elementB/specialSubElementB"/>
<xs:field xpath="@ID"/>
</xs:key>

This way I get the sub-elements of TypeB, but the Problem is, that the ID is in TypeB not in its sub-Elements. The problem is, that I can't refer the parent-element to the ID Normally you could write something like this:
xpath=".//elementB/[specialSubElementB]"/ so only the elements are taken, who have the subElementB. But this doesn't seem to work. I tried it in Avolta XML-Spy with the "Evaluate Path" and gave him the command with the brackets (xpath=".//elementB/[specialSubElementB]"/) and the correct elements were selected but in the selector-element this doesn't seem to work.

I could move the ID-Attribute to each subElement-Type, but it would be much better for my scheme if I would leave it at the parent-element abcType. Are the any work-arounds or does anybody know a solution for this problem?

Any help would be appreciated,
thanks...
Henning.
 

Stan Kitsis MSFT

Usenet Archive
Joined
Dec 15, 2004
Messages
64
Reaction score
0
Hi Henning,

All xpath attributes should use namespace when referring to elements.

<xs:schema .... targetNamespace="myTargetNamespace"
xmlns:myNS="myTargetNamespace" xmlns="myTargetNamespace"...>

<xs:selector xpath=".//myNS:elementB/myNS:specialSubElementB"/>
 

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

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top