xsl-list
[Top] [All Lists]

Using id() when id and idref are in 2 different files

2004-12-13 03:32:35
This is my first posting and I'm sorry if this has been answered many times.
I've tried searching on the archive, Google and so on, but it's tricky when
I have such a hard time even describing my problem.

I'm trying to work out how to use id() when the ID values are in a different
xml file from the one where the IDREFS are. I've been given the task of
converting a play into xml. To avoid having one long file I've decided to
split the acts into separate files and link to them from a title page that
contains the titles and cast list.
 
The cast list contains role elements: <!ELEMENT role (#PCDATA)*> <!ATTLIST
role id ID #REQUIRED>
The other files have various elements that refer to these actors using @who
which is an IDREF e.g.: <!ELEMENT speech (#PCDATA)> <!ATTLIST speech who
IDREFS #IMPLIED>

Using <xsl:template match="speech">
                <xsl:value-of select="id(@who)" />:
                <blockquote> Alas! Poor Yorick...
works fine if everything is in one file but of course when the IDs are no
longer there it fails.

So I have tried using document() to read the castlist into a variable called
$cast. Now I can use <xsl:value-of select="$cast//@id" /> to output the
required values but I can't get it to work with the id()function.
<xsl:value-of select="id(@who)" /> just fails, which doesn't surprise me.
However <xsl:value-of select="$cast//role[(_at_)id = @who]" /> also returns
nothing. Is it because it is now looking for @who within $cast?

<xsl:value-of select="$cast//role[(_at_)id = 'r1']" /> will return the value 
that
has an @id of "r1" so I guess I'm almost there. But that's where I have been
stuck for the past few days. I've also tried reading @who into a $who
variable and using that but that makes no difference.

I'm using the Xalan.jar parser. Hope someone can help and I hope this isn't
too newbie-ish.

Chris Matchett
IT Monkey and Birkbeck Student

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--