Hi Eric,
At 01:08 PM 2/23/2006, you wrote:
Doesn't "position() > 1" evaluate to either 0 or 1?
Not quite: it's either "true()" or "false()" (Boolean values). In
your case, since it's used as a predicate, it has the effect of
selecting all the members of the set $node except the first one.
Presumably, when your template is called, a set of nodes is passed in
as the parameter $node; the recursion trims this set down one node at a time.
Cheers,
Wendell
<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.
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--