[xsl] matching by id in external document()

Subject: [xsl] matching by id in external document()
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Aug 2006 19:35:51 +1200
Hi

This template works - it accesses the correct target element in the external
document based on its id attribute matching the suffix of the local srcfile
attribute.

 <xsl:template match="jump[@srcfile]">
   <xsl:variable name="jfil">
     <xsl:value-of select="substring-before(@srcfile,'#')" />
   </xsl:variable>
   <xsl:variable name="jid">
     <xsl:value-of select="substring-after(@srcfile,'#')" />
   </xsl:variable>
   <xsl:copy>
     <xsl:apply-templates select="@*[local-name() != 'text']"/>
     <xsl:attribute name="text">
       <xsl:value-of select="document($jfil,/)//target[@id = $jid]" />
     </xsl:attribute>
   </xsl:copy>
 </xsl:template>


I was hoping that the following edit would be more efficient (it would
replace the 11th line of the preceding template):

       <xsl:value-of select="document($jfil,/)/id($jid)" />

But this is an invalid XPath expression. What am I doing wrong?

Cheers
Trevor

Current Thread