[xsl] Trying to undestand why template works

Subject: [xsl] Trying to undestand why template works
From: yguaba@xxxxxxxxxxxx
Date: Thu, 23 Feb 2006 15:08:43 -0300

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:when test="$node">
			<xsl:variable name="recursive_result">
				<xsl:call-template name="sum-value">
					<xsl:with-param name="node" select="$node[position() &gt; 1]"/>
					<xsl:with-param name="hourVal" select="$hourVal"/>
		<xsl:value-of select="$recursive_result + number($node[1]/@time * 
			<xsl:value-of select="0"/>

I just don't understand how the select="$node[position() &gt; 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() &gt; 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.


Yahoo! Acesso Gratis - Internet rapida e gratis. Instale o discador agora!

Current Thread