OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] XMLSpy and <key><keyref>

[ Lists Home | Date Index | Thread Index ]

Nada and everybody,
I tried for one more day and I still couldn't figure out how to make the
<key> work. 

I want to represent a recursive 1:n relationship for a database table
AdminUnit (i.e., AdminUnit State consist of many AdminUnits 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 would really, really appreciate any help regarding the mistake I am making
here.

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>

-- 
Markus Seibold
------------------------------
Krebsgasse 6
D-93047 Regensburg
Germany
------------------------------
Email: markus.seibold@gmx.net
Phone: +49 (941) 504 1009
Mobile: +49 (171) 212 6869
FAX: +49 (89) 1488 210457





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS