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 September 10th, 2014, 02:38 PM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default Recursion

Hi, I am running Windows8, Net 2.0 and XML version 1.0. I've done a bit of programming thus far with help from this forum, so once again Thanks to all who share their talent/knowledge with others. In my past conventional programming, you could save much time in repeating common code by writing a separate function and simply referring to it when needed. It does not seem that simple here with XSLT...
Specifically, I have repeating background formatting code to grade flight performance: Excellent = Green, Poor = Red, etc.
I set my flight performance variable like:
<xsl:variable name="ASIMaxNumber"
select="$PointsA[not (. &lt; $PointsA)]" />
I evaluate the variable like:
<tr>
<td><xsl:text>Air Speed Maximum = </xsl:text></td>
<td><xsl:value-of select ="format-number($ASIMaxNumber,'#.00')"/>
<xsl:text> Knots</xsl:text></td>
<xsl:if test= "$ASIMaxNumber &gt; 130">
<td bgcolor="#ff0000">
<xsl:text>Fail</xsl:text>
</td>
</xsl:if>
</tr>
There would be similar code to evaluate $ASIMaxNumber < 110 and for 110 - 130. Understand too that this same evaluation will be performed on other data such as Altitude, Distance, etc.
So for 3 variables, I end up performing the SAME 3 "if test" and applying the SAME background formatting...the only thing changing is the node and its value.
Question: Is there a more efficient way to perform these repetitive tasks than simply repeating the "if:test"? If so, would you show me an example? Thanks so much for any help or reference.
Jake
 
Old September 10th, 2014, 03:46 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Can't see what this has to do with recursion, which is the ability of a function to call itself.

The equivalent of functions in XSLT 1.0 is named templates, which you write using xsl:template name="x" and invoke using xsl:call-template name="x"; you can declare parameters with xsl:param, and supply parameters using xsl:with-param. It's all rather verbose; you would be better off moving to XSLT 2.0 which provides real functions and function calls (there are several XSLT 2.0 processors available on .NET, but not from Microsoft).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
infinite recursion bangbangbogi XSLT 3 May 4th, 2006 05:54 AM
Recursion lincsimp XSLT 1 August 16th, 2005 04:26 PM
recursion yui0329 C# 6 April 28th, 2005 09:36 AM
Recursion shan9 JSP Basics 0 November 17th, 2004 09:29 PM
recursion nulogix PHP How-To 1 June 28th, 2004 03:58 PM





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