473,401 Members | 2,127 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,401 software developers and data experts.

Need help on the "keyref" part of my schema !

I have some XML that must look like this :

<movies>
<movie id="1">
<actor preferredMovieId="1">
<actor preferredMovieId="2">
<actor preferredMovieId="3">
</movie>
<movie id="2">
<actor preferredMovieId="2">
<actor preferredMovieId="2">
</movie>
<movie id="3">
<actor preferredMovieId="1">
<actor preferredMovieId="1">
<actor preferredMovieId="3">
</movie>
</movies>

I could write the xs:key which seems to work fine :

<xs:element name="movies" >
<xs:complexType >
<xs:sequence>
...
</xs:sequence>
</xs:complexType>

<xs:key name="k_movie">
<xs:selector xpath="./target:definition"/>
<xs:field xpath="@id"/>
</xs:key>

</xs:element>

But I could not get anything right to say that "movie/actor/@id" should
point to a "movie/@id".

I hoped that something like this would work, but it does not :

<xs:keyref name="kr_prefferedMovie_movie" refer="k_movie">
<xs:selector xpath="./target:movie/target:actor"/>
<xs:field xpath="@prefferedMovieId"/>
</xs:keyref>

When trying to validate, an error tells me that the value matched by
k_movie is not matched by the referenced key. The key is matched (it
works if I remove the keyref), so I think the problem is that the
context is not the good one.

Of course, this is a simplified version of my real example, so I may
have introduce typos whiles making it, but I really need a working
example !

Regards,
Fabien.
Of course, this is

Sep 26 '05 #1
2 1621
Theoretically, this should work. However, there _are_ quite a lot of
typos in your example, so it's difficult to see exactly why it's not
working. Maybe if you post the whole thing...

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Sep 27 '05 #2
Jaunedeau writes:
<movies>
<movie id="1">
<actor preferredMovieId="1">
<actor preferredMovieId="2">
<actor preferredMovieId="3">
</movie>
. . .
</movies>

I could write the xs:key which seems to work fine :

<xs:element name="movies" >
<xs:complexType >
<xs:sequence>
...
</xs:sequence>
</xs:complexType>

<xs:key name="k_movie">
<xs:selector xpath="./target:definition"/>
<xs:field xpath="@id"/>
</xs:key>

</xs:element>

But I could not get anything right to say that "movie/actor/@id" should
point to a "movie/@id".

I hoped that something like this would work, but it does not :

<xs:keyref name="kr_prefferedMovie_movie" refer="k_movie">
<xs:selector xpath="./target:movie/target:actor"/>
<xs:field xpath="@prefferedMovieId"/>
</xs:keyref>


If your schema's target namespace is what's bound to the 'target'
prefix, you need

<xs:keyref name="kr_prefferedMovie_movie" refer="target:k_movie">

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Sep 30 '05 #3

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

Similar topics

0
by: Olaf Meyer | last post by:
I'm wondering if I can also express uniquness constraints on attributes of objects that I have referenced from somewhere else. To be a bit more precise here a short and simple XML document. The...
3
by: Rabe | last post by:
Hi all, here a little brain-twister (starting to spoil my weekend if I do not find a solution ... ;-) ) What I want to do is to find a XML-Schema expression that builds a grammar for the...
2
by: Ian Pilcher | last post by:
I've managed to figure out how to create a keyref identity constraint as part of an element definition in my schema. Ideally, I would like to make it part of the type definition. In my initial...
0
by: jacksuyu | last post by:
I have two xsd files, in one xsd file, I defined a "key", I'd like to use "keyref" to refer to that "key" from another xsd file. But I always get attribute is empty error. my.xsd is my first xsd...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
6
by: Roland Praehofer | last post by:
Hi! I'm trying to accomplish the following: <root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='teaser.xsd'> <b> <a>John</a> <a>Paul/a>
0
by: mavis | last post by:
Does IntellJ support the checking for "keyref" definition? Why it seems does not work at all? <xs:key name="supported-platforms-name-unique"> <xs:selector...
2
by: bmichel | last post by:
Regarding the XSD schema shown below, I want to modifiy it so that: - the "owner_id" attribute in the "dog" element to exist in one of the "owner" element "id" attribute. - the "id" attribute in...
1
by: brucepickford001 | last post by:
Hi, I have a not simple problem. I want the following XML to be schema valid <PopulationDemographic> <PersonName>Joe Blogs</PersonName> <Age>2</Age> <Category>baby</Category>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.