473,246 Members | 1,528 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,246 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 1352
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: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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...

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.