I am trying to transform an XML document through a series of XSL stylesheets transformations in oXygen. I found the question Is daisy chaining xslt an accepted practice? and Dimitre Novatchev's answer (below) is great: it works perfectly as set out for two pass. I can't seem to get this to work for a third pass however.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vPass1" >
<xsl:apply-templates select="/*/*"/>
</xsl:variable>
<xsl:apply-templates mode="pass2"
select="$vPass1/*"/>
</xsl:template>
<xsl:template match="num[. mod 2 = 1]">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="num" mode="pass2">
<xsl:copy>
<xsl:value-of select=". *2"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I've tried adding a second variable as below (in my problem I'm calling named templates instead of applying to the whole document). What I am calling template2 should be applied to the output of the transformation performed by template1.
Should I be declaring variable $vPass2 somewhere within template1 instead of in the same place as where i declare $vPass1? Or is there something else I'm not getting about how this works?
<xsl:template match="/">
<xsl:variable name="vPass1" >
<xsl:call-template name="template1"/>
</xsl:variable>
<xsl:apply-templates mode="pass2" select="$vPass1/*"/>
<xsl:variable name="vPass2" >
<xsl:call-template name="template2"/>
</xsl:variable>
<xsl:apply-templates mode="pass3" select="$vPass2/*"/>
</xsl:template>
Thanks