[xsl] Context node is within a variable - how to get back?

Subject: [xsl] Context node is within a variable - how to get back?
From: "Tristan Stevens" <tristanstevens@xxxxxxxxxxx>
Date: Fri, 29 Jun 2007 19:08:33 +0100
I have a problem which I am currently solving using a temporary tree within a variable, which I thought would allow me to process the contents of my document multiple times.

For example:

       <Copy attr1="a" attr2="b"/>
       <Copy attr1="c" attr2="d"/>
       <Copy attr1="e" attr2="f"/>

In my scenario, the CopyInformation isn't quite good enough, therefore I need to run some XSLT to get some more information - this I stored in a variable, which I then iterate through to provide multiple copies of the body itself:

<xsl:variable name="Copies">
<xsl:apply-templates select="/Root/IncompleteCopyInformation" mode="ListGeneration" />

<xsl:tempalte match="Copy" mode="ListGeneration">
       ... <!-- some logic going on here -->

<xsl:template match="/">
   <xsl:apply-templates select="$Copies"/>

<xsl:template match="ActualCopy">
   <h1>Copy <xsl:number ... /></h1>
   <xsl:apply-templates select="/Root/Body">
       <xsl:param .... />

This doesn't work because when I attempt to apply-templates to /Root/Body, the context appears to be limited to the variable - how can I get back to the document?

This is largely academic, as I found a way around it by moving the copy derivation code into a massive XPath, however interested to know if there is a solution.



Current Thread