469,271 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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 1396
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Olaf Meyer | last post: by
reply views Thread by jacksuyu | last post: by
6 posts views Thread by Roland Praehofer | last post: by
2 posts views Thread by bmichel | last post: by
1 post views Thread by brucepickford001 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.