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

J

Jaunedeau

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
 
P

Priscilla Walmsley

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...
 
H

Henry S. Thompson

Jaunedeau said:
<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: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top