[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: key and keyref problems

  • From: "Michael Kay" <mike@s...>
  • To: "'pau carre'" <pau.carre@g...>,<xml-dev@l...>
  • Date: Fri, 2 Feb 2007 16:56:24 -0000

RE:  key and keyref problems
Your XML isn't well-formed. But when I change it to this:

<travelAgency>
       <countries>
               <country name = "Brasil" code ="BR"/>
               <country name = "United States of America" code ="USA"/>
               <country name = "Norway" code ="NO"/>
       </countries>
       <travel>
               <country code = "NO"/>
               <country code = "BRAS"/>
       </travel>
</travelAgency>

and run it against this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name = "travelAgency" type="xs:anyType">
       <xs:key name="countryID">
               <xs:selector xpath="./countries/country"/>
               <xs:field xpath="@code"/>
       </xs:key>

       <xs:keyref name="countryIDRef" refer="countryID">
               <xs:selector xpath="./travel/country"/>
               <xs:field xpath="@code"/>
       </xs:keyref>
</xs:element>
</xs:schema>

Saxon says:

Validation error on line 11 column 16 of file:/c:/temp/travel.xml:
  No referenced value found for keyRef {countryIDRef}: "BRAS" (See
  http://www.w3.org/TR/xmlschema-1/#cvc-identity-constraint clause 4.3)
Validation of source document failed

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: pau carre [mailto:pau.carre@g...] 
> Sent: 02 February 2007 16:12
> To: xml-dev@l...
> Subject:  key and keyref problems
> 
> Hi all,
> I am trying to use key and refkey elements in a XML Schema.
> 
> The XML instances look like:
> 
> <travelAgency>
>        <countries>
>                <country name = "Brasil" code ="BR">
>                <country name = "United States of America" code ="USA">
>                <country name = "Norway" code ="NO">
>        </countires>
>        <travel>
>                <country code = "NO">
>                <country code = "BRAS">
>        <travel>
> </TravelAgency>
> 
> And the XML Schema is (omitting noise with "..."):
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name = "travelAgency" ...>
>        <xs:complexType>
>                ...
>        </xs:complexType>
> 
>        <xs:key name="countryID">
>                <xs:selector xpath="./countries/country"/>
>                <xs:field xpath="@code"/>
>        </xs:key>
> 
>        <xs:keyref name="countryIDRef" refer="countryID">
>                <xs:selector xpath="./travel/country"/>
>                <xs:field xpath="@code"/>
>        </xs:keyref>
> </xs:element>
> 
> The problem is that even wrong XML instances (like the one 
> written above with BRAS code) are found right by the 
> validator. I have unsuccessfully tried to change the xpath 
> but I did not succeed.
> Searching for inet I found that the namespaces should be 
> added in xpath declaration but I do not know how to do it, 
> and if it is necessary in my case.
> 
> 
> Thanks in advance,
> 
> Pau
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l... List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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