Subject: [xsl] Trying to undestand why template works From: yguaba@xxxxxxxxxxxx Date: Thu, 23 Feb 2006 15:08:43 -0300 |
Hello, After some digging and experimenting, I finally got a stylesheet to do what I wanted. Among other things, it uses the template below. Problem is, I don't really understand WHY this template works, and would very much like to. Here's the template: <xsl:template name="sum-value"> <xsl:param name="node"/> <xsl:param name="hourVal"/> <xsl:choose> <xsl:when test="$node"> <xsl:variable name="recursive_result"> <xsl:call-template name="sum-value"> <xsl:with-param name="node" select="$node[position() > 1]"/> <xsl:with-param name="hourVal" select="$hourVal"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$recursive_result + number($node[1]/@time * $hourVal)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="0"/> </xsl:otherwise> </xsl:choose> </xsl:template> I just don't understand how the select="$node[position() > 1]" bit works. I assume that with each recursion this is selecting the next child of the input node (param "node"), but have no idea how or why. Doesn't "position() > 1" evaluate to either 0 or 1? If so, where is the input node becoming the next child of the original input node (at the first level of the recursion)? Or, if my question doesn't make any sense, how the heck is the recursion moving on to the next child of the input node in order to add them all up? Thanks in advance to anyone who can shed any light on this issue. Erik _______________________________________________________ Yahoo! Acesso Gratis - Internet rapida e gratis. Instale o discador agora! http://br.acesso.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to prevent that XML a, Wendell Piez | Thread | Re: [xsl] Trying to undestand why t, Wendell Piez |
Re: [xsl] Trying to undestand why t, Wendell Piez | Date | Re: [xsl] Trying to undestand why t, Jon Gorman |
Month |