Re: AW: [xsl] variables

Subject: Re: AW: [xsl] variables
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 31 May 2001 14:11:53 +0100
Hi André,

> In your "evaluate-paths"-template you used the <xsl:copy-of>
> instruction in order to return a copy of the result nodes (s. a) )
> which will be the RTF of the "var1-rtf" variable. Is this right ? I
> thought that the result of the <xsl:copy-of> instruction would be
> copied directly into the result-tree. Could you please give me an
> answer to that question.

The result tree is the result of processing the entire stylesheet -
that's what gets output ultimately.

If you set a variable (or parameter) using its content then you get a
'result tree fragment' - a bit of a result tree that you might
completely ignore or you might copy to the result, perhaps multiple
times. Creating nodes while setting the value of a variable, however
you do it, including using xsl:copy-of, doesn't make those nodes
automatically appear in the result tree.

Actually, if you're going down the copying route you don't have to use
recursion to evaluate the paths, you could use xsl:for-each instead:

   <xsl:variable name="var1-rtf">
      <!-- store the current node in $data -->
      <xsl:variable name="data" select="." />
      <!-- iterate over the paths -->
      <xsl:for-each select="document('doc2.xml')/paths/*">
         <!-- store the current path in $path -->
         <xsl:variable name="path" select="." />
         <!-- change context back to $data -->
         <xsl:for-each select="$data">
            <!-- make a copy of the result of evaluating the path -->
            <xsl:copy-of select="xalan:evaluate($path)" />
         </xsl:for-each>
      </xsl:for-each>
   </xsl:variable>
   <xsl:variable name="var1" select="xalan:nodeSet($var1-rtf)" />

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread