[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Using id() when id and idref are in 2 different files
From: "Chris Matchett" <matchett79@xxxxxxxxxxx>
Date: Mon, 13 Dec 2004 10:32:35 -0000
xsl idref
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[@id = @who]" /> also returns
nothing. Is it because it is now looking for @who within $cast?

<xsl:value-of select="$cast//role[@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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.