473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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
1 1356
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have two complex (A and B) types which both inherit from a common base typ (Base). A refers B using a xs:IDREF element named...
0
by: Markus Seibold | last post by:
Hello NG, sorry for pasting that much code but I just can't figure out how get the <key><keyref> to work in XML Schema. I am using XMLSpy 4.3 for editing my XML. I want to represent a...
5
by: Russell O'Connor | last post by:
The following XML and Schema doesn't validate in Visual Studio .NET 2003. Is there some mistake I'm making, or is VS.NET in error. The error is r:\test2.xml(3): The key sequence 'foo' in Keyref...
0
by: mark.van.der.voort | last post by:
Hi, I have defined a simple key/keyref validation for describing a tree. <xs:key name="key_member"> <xs:selector xpath=".//member"/> <xs:field xpath="@id"/> </xs:key> <xs:keyref...
0
by: jacksuyu | last post by:
I have two xsd files, in one xsd file, I defined a "key", I'd like to use "keyref" to refer to that "key" from another xsd file. But I always get attribute is empty error. my.xsd is my first xsd...
1
by: Dmitry Martynov | last post by:
Hi I have a question whether XmlValidatingReader doesn't check keyref constrain (the same with key constraint) or I do smth wrong. I have the following schema <?xml version="1.0"...
0
by: Kent Boogaart | last post by:
Hi, Suppose an XSD as follows: <xsd:complexType name="myType"> <xsd:complexContent> <xsd:extension base="myBaseType"> <xsd:sequence> <xsd:element name="thing" minOccurs="0"...
2
by: svestin | last post by:
Hi All! I run into a problem defining a XSD schema with KEYREF references. Is it possible to use KEYREF with nillable fields? Just like a database where a FK could be null. In the example...
0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have a complex type "AExtended" which inherits from a base type "ABase". Both are allowed to be instantiated under the "Root"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.