473,326 Members | 2,680 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.

<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 <AdminUnitName> element which should be the key. I then
declared the <keyref> in the context of the <SubAdminUnits> element and
specified the XPath to the <SubAdminUnitName> 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
<SubAdminUnitName>.

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="http://www.opentourism.org"
xmlns:gml="http://www.opengis.net/gml" elementFormDefault="unqualified">

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

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

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

<include schemaLocation="TourML_DataTypes_1-0.xsd"/>

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

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

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

<element name="Country" type="utour:CountryType">

<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="SuperAdminUnit_SubAdminUnit_Key">

<selector xpath="CountryAdminUnits/AdminUnit"/>

<field xpath="AdminUnitName"/>

</key>

</element>

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

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

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

<complexType name="_CountryAdminUnit">

<annotation>

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

</annotation>

<sequence>

<element name="AdminUnit" type="utour:AdminUnitType"/>

</sequence>

</complexType>

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

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

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

<complexType name="CountryType">

<sequence>

<element name="CountryID" type="utour:CountryIDType"/>

<element name="CountryName" type="utour:MaxCharacter30Type"/>

<element name="CountryPhoneCode" type="integer"/>

<element name="CountryGratuityGuideline"
type="utour:MaxCharacter100Type" minOccurs="0"/>

<element name="CountryBestTravelTime"
type="utour:MaxCharacter100Type" minOccurs="0"/>

<element name="CountryAdminUnits" type="utour:_CountryAdminUnit"
minOccurs="0" maxOccurs="unbounded"/>

</sequence>

</complexType>

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

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

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

<complexType name="AdminUnitType">

<sequence>

<element name="AdminUnitName" type="utour:MaxCharacter128Type"/>

<element name="SubAdminUnits" type="utour:_SubAdminUnit"
minOccurs="0" maxOccurs="unbounded">

<keyref name="SuperAdminUnit_SubAdminUnit_Ref"
refer="utour:SuperAdminUnit_SubAdminUnit_Key">

<selector xpath="."/>

<field xpath="SubAdminUnitName"/>

</keyref>

</element>

<element name="AdminUnitType">

<simpleType>

<restriction base="string">

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

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

<enumeration value="Bundesland" xml:lang="de"/>

<enumeration value="Regierungsbezirk" xml:lang="de"/>

<enumeration value="Landkreis" xml:lang="de"/>

</restriction>

</simpleType>

</element>

</sequence>

</complexType>

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

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

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

<complexType name="_SubAdminUnit">

<annotation>

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

</annotation>

<sequence>

<element name="SubAdminUnitName" type="utour:MaxCharacter128Type"/>

</sequence>

</complexType>

</schema>

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

<utour:Country xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:utour="http://www.opentourism.org"
xsi:schemaLocation="http://www.opentourism.org
D:\Eigene~1\Studium\diplom~1\TourML\TourML_1-0\___TourML_Geography_1-0.xsd">

<CountryID>US</CountryID>

<CountryName>United States of America</CountryName>

<CountryPhoneCode>1</CountryPhoneCode>

<CountryAdminUnits>

<AdminUnit>

<AdminUnitName>Georgia</AdminUnitName>

<SubAdminUnits>

<SubAdminUnitName>XXXClarke County</SubAdminUnitName>

</SubAdminUnits>

<SubAdminUnits>

<SubAdminUnitName>Oconee County</SubAdminUnitName>

</SubAdminUnits>

<AdminUnitType>State</AdminUnitType>

</AdminUnit>

</CountryAdminUnits>

<CountryAdminUnits>

<AdminUnit>

<AdminUnitName>Clarke County</AdminUnitName>

<SubAdminUnits>

<SubAdminUnitName></SubAdminUnitName>

</SubAdminUnits>

<AdminUnitType>County</AdminUnitType>

</AdminUnit>

</CountryAdminUnits>

<CountryAdminUnits>

<AdminUnit>

<AdminUnitName>Oconee County</AdminUnitName>

<SubAdminUnits>

<SubAdminUnitName></SubAdminUnitName>

</SubAdminUnits>

<AdminUnitType>County</AdminUnitType>

</AdminUnit>

</CountryAdminUnits>

</utour:Country>

Jul 20 '05 #1
0 1774

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

Similar topics

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"...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.