View Single Post
  #2 (permalink)  
Old April 4th, 2007, 02:33 PM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts

>I want my final transform to be a one-step process, so I capture the results of the previous transform in a variable

Actually it's a two-stage process whether the code is all in one stylesheet or in two. Writing a transformation pipeline within a single stylesheet is perhaps operationally more convenient than writing it as multiple stylesheets, but the coding is more awkward because of the need to use multiple modes, it can be harder to debug, it's no faster, and you get fewer opportunities to create reusable or reconfigurable code. Also it can't be done using strict XSLT 1.0 without the node-set() extension.

But if you want to do it, the pattern is

<xsl:variable name="temp">
  <xsl:apply-templates mode="phase1"/>

<xsl:apply-templates select="$temp" mode="phase2"/>

or in XSLT 1.0

<xsl:apply-templates select="xx:node-set($temp)" mode="phase2"/>

where xx:node-set() is an extension function provided in nearly all XSLT 1.0 processors (but in different vendor namespaces).

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote