473,698 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSD keyref problem

Hi all,

I am currently working on creating an XSD schema. I have an element defined
that should be self-refering (child-parent principle). Here is a sample:

<GWLC>
<GROUPS>
<GROUP>
<NAME>ParentGro up</NAME>
<PARENT></PARENT>
</GROUP>
<GROUP>
<NAME>ChildGrou p1</NAME>
<PARENT>ParentG roup</PARENT>
</GROUP>
</GROUPS>
</GWLC>

The schema a currently have is valid, but it does not validate the existance
of a parent group (foreignkey constraint). Secondly, I want each name to be
uniqe. The applicable section off the schema:

<!-- *************** *************** ****** -->
<!-- * Description of the GROUPS element* -->
<!-- *************** *************** ****** -->
<xs:element name="GROUPS" id="GROUPS">
<xs:complexType >
<xs:sequence>
<xs:element ref="GROUP" maxOccurs="unbo unded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="UC_Group" >
<xs:selector xpath="./GROUP"></xs:selector>
<xs:field xpath="NAME"></xs:field>
</xs:unique>
</xs:element>

<!-- *************** *************** ***** -->
<!-- * Description of the GROUP element* -->
<!-- *************** *************** ***** -->
<xs:element name="GROUP" id="GROUP">
<xs:complexType >
<xs:sequence>
<xs:element name="NAME"/>
<xs:element name="PARENT"/>
</xs:sequence>
</xs:complexType>
<xs:key name="PK_GROUP" >
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="NAME"/>
</xs:key>
<xs:keyref name="FK_GROUP_ GROUP" refer="PK_GROUP ">
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="PARENT"/>
</xs:keyref>
</xs:element>
Thanks for helping!

Gerry
Jan 8 '07 #1
0 1374

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3271
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 Ref_to_A. Both are allowed to be instantiated under the root element by declaring an element of the base class. I want to have type safety for the reference by using key/keyref.
0
1804
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 recursive 1:n relationship between a database table AdminUnit (i.e., States consist of Counties).
5
6511
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 fails to refer to some key. An error occurred at , (3, 6). Any help is appreciated. Here is the schema. <?xml version="1.0" ?> <xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/test2.xsd" xmlns:mstns="http://tempuri.org/test2.xsd"
2
1648
by: Jaunedeau | last post by:
I have some XML that must look like this : <movies> <movie id="1"> <actor preferredMovieId="1"> <actor preferredMovieId="2"> <actor preferredMovieId="3"> </movie> <movie id="2"> <actor preferredMovieId="2">
1
2859
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" encoding="utf-8"?> <xs:schema id="module" targetNamespace="http://tempuri.org/module.xsd"
0
1155
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" maxOccurs="unbounded">
2
1810
by: Kent Boogaart | last post by:
Hello, I have a complex type defined in its own schema as follows: <xsd:complexType name="myType"> <xsd:complexContent> <xsd:extension base="myBaseType"> <xsd:attribute name="parentId" type="xsd:string" use="optional"/> </xsd:extension> </xsd:complexContent>
2
2847
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 below the tag <Owner> is nillable and also used as FIELD in the KEYREF.
6
1804
by: Roland Praehofer | last post by:
Hi! I'm trying to accomplish the following: <root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='teaser.xsd'> <b> <a>John</a> <a>Paul/a>
0
1639
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" element by declaring an element of the base class with name "A" and either "xsi:type=ABase" or "xsi:type=AExtended". I want to have type safety for the reference "Ref_to_AExtended" from
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.