Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2012, 05:10 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
Default Optimising recursive calls

Hi guys,

I execute recursive calls like this:

<xsl:template name="recursionTemplate">

<xsl:param name="counter" select="1"/>
<xsl:param name="vehCount" select="1"/>
<xsl:param name="ref"/>
<xsl:if test="$counter &lt;= $vehCount">

<fo:table-cell border="solid 0px black"
text-align="left">
<fo:block font-size="8pt">
<fo:block font-size="8pt">
<xsl:value-of select="java:getName($ref,$counter)"/>
</fo:block>
</fo:block>
</fo:table-cell>

<xsl:call-template name="recursionTemplate">
<xsl:with-param name="counter" select="$counter + 1"/>
<xsl:with-param name="vehCount" select="$vehCount"/>
<xsl:with-param name="ref" select="$ref"/>
</xsl:call-template>
</xsl:if>

</xsl:template>


and I call the template like this:

<xsl:call-template name="recursionTemplate">
<xsl:with-param name="vehCount" select="$vehicleCount"/>
<xsl:with-param name="ref" select="$helperClassRef"/>
</xsl:call-template>


There are several other methods which I will be calling getEngineCapacity(), getMileage() on each vehicle by iterating over them. I do not want to have separate recursion template for each method that I want to call since that will lead to a lot of redundant code.

I learned that I cannot pass the method name dynamically and call it in the recursion template.

What is the best way to achieve this? One thought that came to my mind is defining the method call in a template and passing this template to the recursion template. If this is possible what would be the syntax for it?
 
Old March 26th, 2012, 05:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Is this XSLT 1.0 or XSLT 2.0?

You might take a look at Dimitre Novatchev's FXSL library which provides lots of powerful mechanisms for higher-order functional programming in XSLT. It has variants for XSLT 1.0 and XSLT 2.0.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old March 26th, 2012, 05:29 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
Default

This is XSLT 1.0. I will take a look at that and see if it suits my need. Thanks Michael.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ex 20-2 Recursive calls zavodney BOOK: Stephens' Visual Basic Programming 24-Hour Trainer 5 August 26th, 2011 09:48 PM
Profiler and procedure calls joxa83 SQL Server 2005 0 September 9th, 2008 03:41 AM
Optimising CPU Usage avbabu BOOK: Professional Crystal Reports for VS.NET 0 December 15th, 2004 07:23 AM
detecting calls while online arbe1988 Beginning VB 6 0 October 3rd, 2004 03:53 PM
function calls ricmar Access VBA 3 September 24th, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.