473,395 Members | 1,870 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,395 software developers and data experts.

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>ParentGroup</NAME>
<PARENT></PARENT>
</GROUP>
<GROUP>
<NAME>ChildGroup1</NAME>
<PARENT>ParentGroup</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="unbounded"/>
</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 1356

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...
2
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...
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: 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"...
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...
6
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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,...

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.