467,188 Members | 1,484 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,188 developers. It's quick & easy.

Verifying the contents with key, keyref

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.

Jun 15 '06 #1
  • viewed: 1211
Share:
1 Reply
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"/>

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

<ko**********@googlemail.com> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com...
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.

Jun 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by peterpeter | last post: by
reply views Thread by Markus Seibold | last post: by
5 posts views Thread by Russell O'Connor | last post: by
reply views Thread by mark.van.der.voort@gmail.com | last post: by
reply views Thread by jacksuyu@gmail.com | last post: by
reply views Thread by Kent Boogaart | last post: by
2 posts views Thread by svestin@bigfoot.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.