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

>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:variable>

<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
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote