[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|