473,657 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I have some XML that must look like this :

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

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

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

<xs:key name="k_movie">
<xs:selector xpath="./target:definiti on"/>
<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_preffe redMovie_movie" refer="k_movie" >
<xs:selector xpath="./target:movie/target:actor"/>
<xs:field xpath="@preffer edMovieId"/>
</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 1646
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 preferredMovieI d="1">
<actor preferredMovieI d="2">
<actor preferredMovieI d="3">
</movie>
. . .
</movies>

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

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

<xs:key name="k_movie">
<xs:selector xpath="./target:definiti on"/>
<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_preffe redMovie_movie" refer="k_movie" >
<xs:selector xpath="./target:movie/target:actor"/>
<xs:field xpath="@preffer edMovieId"/>
</xs:keyref>


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

<xs:keyref name="kr_preffe redMovie_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
1622
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 "objects" have a key constraint on the id attribute, i.e. they need to be unique. The object-ref element may reference the previously defined objects and hence has a keyref constraint on the id attribute. I would now like to furhter restrict the...
3
1981
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 following XML document (fragment): <grouping_document> <app_list>
2
1148
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 experiments, it doesn't look like this is possible. (I've actually managed to add a constraint to an element within a complex type, and the parser accepts it, but it doesn't appear to do anything.) A little bit of reflection leads me to think...
0
1583
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 file with "key", myphone.xsd is the keyref file which need to refer to the "key" Thanks. my.xsd:
3
2756
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. In the samples/data directory, I ran the following command for all the files: DOMPrint -n -s -f -v=always <filename>
6
1804
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
1185
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 xpath=".//supported-platforms/platform"/> <xs:field xpath="."/> </xs:key> <xs:keyref name="platforms-name-ref"
2
567
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 the "owner" element is unique. How should I modify the XSD? Examples (in the xml): Example 1 should be validated == Example 1 ==
1
1929
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> </PopulationDemographic>
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.