XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Randyll PandohieSubject: Problems with keyref
Author: Randyll Pandohie
Date: 23 Mar 2006 06:09 PM
Hi,
I am getting the following error:
The keyref 'coursecoursetaught' refers to a key/unique that is out of scope. Whenever I try to validate the XML below with the Schema. Can anyone help.


----------XML-------------------------------------
<?xml version="1.0"?>
<universityinformation xmlns="http://www.mydomain.com/project"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mydomain.com/project un.xsd">

<course>
<code>CS63A</code>
</course>

<course>
<code>CS62A</code>
</course>

<lecturer>
<name>
<firstname>ra</firstname>
<middlename>a</middlename>
<lastname>asd</lastname>
</name>
<address type="home"></address><phone type="mobile">655-3323</phone>
<age>1</age><sex>M</sex>
<coursestaught>
<coursetaught>
<code>CS63A</code>
<semester>1</semester>
<year>1951</year>
</coursetaught>



</coursestaught>
<officehours>

<officehour>
<day></day>
<timeperiod></timeperiod>
</officehour>

<officehour>
<day></day>
<timeperiod></timeperiod>
</officehour>

<officehour>
<day></day>
<timeperiod></timeperiod>
</officehour>
<officehour>
<day></day>
<timeperiod></timeperiod>
</officehour>
</officehours>


</lecturer>

<lecturer>
<name>
<firstname>ra</firstname>
<middlename>a</middlename>
<lastname>asd</lastname>
</name>
<address type="board">ghj</address>
<phone type="home">862-655-6923</phone>
<age>12</age>
<sex>M</sex>
<coursestaught>
<coursetaught>
<code>CS63A</code>
<semester>1</semester>
<year>1951</year>
</coursetaught>



</coursestaught>
</lecturer>



</universityinformation>
----------Schema------------------------------------
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:target="http://www.mydomain.com/project"
targetNamespace="http://www.mydomain.com/project"
elementFormDefault="qualified">



<element name="universityinformation" type="target:univType"/>



<complexType name="univType">
<group ref="target:UnivGroup" minOccurs="0" maxOccurs="unbounded"/>
</complexType>

<group name="UnivGroup">
<choice>
<element name="student" type="target:studentInfo"/>
<element name="lecturer" type="target:lecturerInfo" />
<element name="course" type="target:courseInfo">
<key name="courseKey1" >
<selector xpath="code" />
<field xpath="." />
</key>
</element>
</choice>
</group>

<complexType name="studentInfo">
<complexContent>
<extension base="target:personInfo">
<sequence>
<element name="id" type="target:uwi-id"/>
<element name="major" type="string" minOccurs="0" maxOccurs="unbounded"/>
<element name="coursestaken" type="target:courseResultInfo" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>

<complexType name="lecturerInfo">
<complexContent>
<extension base="target:personInfo">
<sequence>
<element name="coursestaught" type="target:courseTaughtInfo" minOccurs="0" maxOccurs="unbounded"/>
<element name="officehours" type="target:officeInfo" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>

<complexType name="courseInfo">
<all>
<element name="code" type="target:codeValues" />
<element name="title" type="string" />
<element name="description" type="string" />
<element name="prerequisites" type="string" />
</all>
</complexType>

<complexType name="personInfo">
<sequence>
<element name="name" type="target:nameInfo"/>
<element name="address" type="target:addressInfo"/>
<element name="phone" type="target:phoneInfo"/>
<element name="age" type="positiveInteger"/>
<element name="sex" type="target:gender"/>
</sequence>
</complexType>

<complexType name="nameInfo">
<all>
<element name="firstname" type="string"/>
<element name="middlename" type="string"/>
<element name="lastname" type="string"/>
</all>
</complexType>


<simpleType name="addressType">
<restriction base="string">
<enumeration value="home"/>
<enumeration value="board"/>
</restriction>
</simpleType>

<complexType name="addressInfo">
<simpleContent>
<extension base="string">
<attribute name="type" type="target:addressType" use="required"/>
</extension>
</simpleContent>
</complexType>

<simpleType name="gender">
<restriction base="string">
<pattern value="M|F"/>
</restriction>
</simpleType>

<simpleType name="phoneType">
<restriction base="string">
<enumeration value="home"/>
<enumeration value="work"/>
<enumeration value="mobile"/>
</restriction>
</simpleType>

<complexType name ="phoneInfo">
<simpleContent>
<extension base="target:phoneNumbers">
<attribute name="type" type="target:phoneType" use="required"/>
</extension>
</simpleContent>

</complexType>

<simpleType name="phoneNumbers">
<restriction base="string">
<pattern value="([0-9][0-9][0-9]-[0-9][0-9][0-9][0-9])|([0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9])"/>
</restriction>
</simpleType>

<simpleType name="uwi-id">
<restriction base="positiveInteger">
<pattern value="[0-9]{8}"/>
</restriction>
</simpleType>

<complexType name="courseResultInfo">
<sequence>
<element name="courseresult">
<complexType>
<sequence>
<element name="code" type="target:codeValues"/>
<element name="examdate" type="date"/>
<element name="mark" type="positiveInteger"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>

<complexType name="courseTaughtInfo">
<sequence>
<element name="coursetaught">
<complexType>
<sequence>
<element name="code">
<keyref name="coursecoursetaught" refer="target:courseKey1" >
<selector xpath="." />
<field xpath="." />
</keyref>

</element>
<element name="semester" type="target:semesterValues"/>
<element name="year" type="target:yearValues"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>

<simpleType name="semesterValues">
<restriction base="positiveInteger">
<pattern value="1|2"/>
</restriction>
</simpleType>

<simpleType name="yearValues">
<restriction base="positiveInteger">
<minInclusive value="1950"/>
<totalDigits value="4"/>
</restriction>
</simpleType>

<simpleType name="codeValues">
<restriction base="string">
<pattern value="([A-Z]{1,2}[0-9][0-9][A-Z])|([A-Z]{4}-[0-9]{4})"/>
</restriction>
</simpleType>



<complexType name="officeInfo">
<sequence>
<element name="officehour" minOccurs="4" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="day" type="string"/>
<element name="timeperiod" type="string"/>

</sequence>
</complexType>
</element>
</sequence>
</complexType>



</schema>

Postnext
Minollo I.Subject: Problems with keyref
Author: Minollo I.
Date: 23 Mar 2006 09:48 PM
Take a look at Alberto's post at the bottom of this thread:
http://www.stylusstudio.com/~ssdn/default.asp?action=9&read=3469&fid=23

Minollo

Posttop
Randyll PandohieSubject: Problems with keyref
Author: Randyll Pandohie
Date: 24 Mar 2006 09:15 AM
Hi,
The thread did explain it all, I simply moved the key and keyref to the root and it worked fine.

Thanks.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.