Doing the apply-templates in a variable is the right thing to do. I don't understand what you mean by saying this "mangles/eliminates the html tags in the output". Perhaps you need to show us more of your code, and perhaps the input and/or output. What are you actually doing with the variable once you've created it? What you need to do is to use xsl:copy-of to copy it to the output (twice).
 
Michael Kay
http://www.saxonica.com/
 
 


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of jeff isenhart
Sent: 15 March 2005 21:19
To: saxon-help@lists.sourceforge.net
Subject: [saxon] avoiding apply-templates duplication

Hi all,

 

I am using saxon to output html and I notice that I am applying the same template twice. Normally I have no problem with this, but the apply-templates call in this particular case is expensive for large input data. I am seeking a simple way to make a single template call. I tried (as a hack) using a variable like so:

 

    <xsl:variable name="colsumm">

<xsl:apply-templates select="groupsummary/col" mode="summary">

                        <xsl:with-param name="rowtype" select="’sum1’"/>

            </xsl:apply-templates>

    </xsl:variable>

 

But this (to no surprise) mangles/eliminates the html tags in the output. Any help is appreciated.

 

Jeff

Example xsl:  

 

<xsl:template match="data//group" mode="normal">

 

<!-- do some stuff here -->

<!--  generate attribute information for header -->

 

<!--  build summary columns for header row……… -->

<xsl:apply-templates select="groupsummary/col" mode="summary">

                        <xsl:with-param name="rowtype" select="’sum1’"/>

            </xsl:apply-templates>

 

<!-- do some more stuff here -->

<!--  generate attribute information for summary -->

 

<!--  build summary columns for summary row……… -->

<xsl:apply-templates select="groupsummary/col" mode="summary">

                        <xsl:with-param name="rowtype" select="’sum1’"/>

            </xsl:apply-templates>

 

</xsl:template>