473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<key><keyref> does not work in XMLSpy

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).

I declared the <key> element in the context of <country> and specified the
XPath to the <AdminUnitNam e> element which should be the key. I then
declared the <keyref> in the context of the <SubAdminUnit s> element and
specified the XPath to the <SubAdminUnitNa me> element which should be the
foreign key pointing to the primary key.

I also pasted a XML instance document at the end of this message. The
document validates in XMLSpy although I specified a non-existend
<SubAdminUnitNa me>.

I just can't figure out why this doesn't work. Could it be that the code
actually is correct but XMLSpy cannot handle the <key><keyref> elements?

I'd really appreciate any help!!!

Thanks, Markus

<?xml version="1.0" encoding="UTF-8"?>

<schema targetNamespace ="http://www.opentourism .org"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:utour="ht tp://www.opentourism .org"
xmlns:gml="http ://www.opengis.net/gml" elementFormDefa ult="unqualifie d">

<!-- =============== =========== -->

<!-- include/import of other schemas -->

<!-- =============== =========== -->

<include schemaLocation= "TourML_DataTyp es_1-0.xsd"/>

<!-- =============== ========= -->

<!-- ===== Country element ===== -->

<!-- =============== ========= -->

<element name="Country" type="utour:Cou ntryType">

<annotation>

<documentation> Country is declared as sub-element of the schema
element; it can function as a root element in an instance
document.</documentation>

</annotation>

<key name="SuperAdmi nUnit_SubAdminU nit_Key">

<selector xpath="CountryA dminUnits/AdminUnit"/>

<field xpath="AdminUni tName"/>

</key>

</element>

<!-- =============== =============== ======== -->

<!-- ===== Country - AdminUnit Relationship ===== -->

<!-- =============== =============== ======== -->

<complexType name="_CountryA dminUnit">

<annotation>

<documentation> Administrative Units that belong to a certain
country. _CountryAdminUn it is the correspondent to the 1:n relationship
between Country and AdminUnit in TourDM.</documentation>

</annotation>

<sequence>

<element name="AdminUnit " type="utour:Adm inUnitType"/>

</sequence>

</complexType>

<!-- =============== ====== -->

<!-- ===== CountryType==== = -->

<!-- =============== ====== -->

<complexType name="CountryTy pe">

<sequence>

<element name="CountryID " type="utour:Cou ntryIDType"/>

<element name="CountryNa me" type="utour:Max Character30Type "/>

<element name="CountryPh oneCode" type="integer"/>

<element name="CountryGr atuityGuideline "
type="utour:Max Character100Typ e" minOccurs="0"/>

<element name="CountryBe stTravelTime"
type="utour:Max Character100Typ e" minOccurs="0"/>

<element name="CountryAd minUnits" type="utour:_Co untryAdminUnit"
minOccurs="0" maxOccurs="unbo unded"/>

</sequence>

</complexType>

<!-- =============== ======== -->

<!-- ===== AdminUnitType ===== -->

<!-- =============== ======== -->

<complexType name="AdminUnit Type">

<sequence>

<element name="AdminUnit Name" type="utour:Max Character128Typ e"/>

<element name="SubAdminU nits" type="utour:_Su bAdminUnit"
minOccurs="0" maxOccurs="unbo unded">

<keyref name="SuperAdmi nUnit_SubAdminU nit_Ref"
refer="utour:Su perAdminUnit_Su bAdminUnit_Key" >

<selector xpath="."/>

<field xpath="SubAdmin UnitName"/>

</keyref>

</element>

<element name="AdminUnit Type">

<simpleType>

<restriction base="string">

<enumeration value="State" xml:lang="en-US"/>

<enumeration value="County" xml:lang="en-US"/>

<enumeration value="Bundesla nd" xml:lang="de"/>

<enumeration value="Regierun gsbezirk" xml:lang="de"/>

<enumeration value="Landkrei s" xml:lang="de"/>

</restriction>

</simpleType>

</element>

</sequence>

</complexType>

<!-- =============== =============== ======== -->

<!--===== AdminUnit Recursive Relationship ===== -->

<!-- =============== =============== ======== -->

<complexType name="_SubAdmin Unit">

<annotation>

<documentation> _SubAdminUnit is the correspondent to the 1:n
recursive relationship between AdminUnit and AdminUnit in
TourDM.</documentation>

</annotation>

<sequence>

<element name="SubAdminU nitName" type="utour:Max Character128Typ e"/>

</sequence>

</complexType>

</schema>

<?xml version="1.0" encoding="UTF-8"?>

<utour:Countr y xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:utour="ht tp://www.opentourism .org"
xsi:schemaLocat ion="http://www.opentourism .org
D:\Eigene~1\Stu dium\diplom~1\T ourML\TourML_1-0\___TourML_Geo graphy_1-0.xsd">

<CountryID>US </CountryID>

<CountryName>Un ited States of America</CountryName>

<CountryPhoneCo de>1</CountryPhoneCod e>

<CountryAdminUn its>

<AdminUnit>

<AdminUnitName> Georgia</AdminUnitName>

<SubAdminUnit s>

<SubAdminUnitNa me>XXXClarke County</SubAdminUnitNam e>

</SubAdminUnits>

<SubAdminUnit s>

<SubAdminUnitNa me>Oconee County</SubAdminUnitNam e>

</SubAdminUnits>

<AdminUnitType> State</AdminUnitType>

</AdminUnit>

</CountryAdminUni ts>

<CountryAdminUn its>

<AdminUnit>

<AdminUnitName> Clarke County</AdminUnitName>

<SubAdminUnit s>

<SubAdminUnitNa me></SubAdminUnitNam e>

</SubAdminUnits>

<AdminUnitType> County</AdminUnitType>

</AdminUnit>

</CountryAdminUni ts>

<CountryAdminUn its>

<AdminUnit>

<AdminUnitName> Oconee County</AdminUnitName>

<SubAdminUnit s>

<SubAdminUnitNa me></SubAdminUnitNam e>

</SubAdminUnits>

<AdminUnitType> County</AdminUnitType>

</AdminUnit>

</CountryAdminUni ts>

</utour:Country>

Jul 20 '05 #1
0 1798

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

Similar topics

0
1153
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">
0
7612
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...
0
7922
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. ...
0
7964
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...
0
6281
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...
0
5218
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.