[email protected] wrote:
> a short small question.
>
> I could iterate through my XML until i find the OrderNumber witch i
> now use. Until that point i add all OrderSums together.
>
> So:
> First Oder: I iterate to order 1 check -> Add the OrderSum -> and
> step out of my iteration, because the compared OrderNumbers are
> equal.
> Now i iterate to Order 2: I iterate to order 1 -> Add the OrderSum ->
> check if the OrderNumber is eqal ( will be false) -> I iterate to
> order 2 -> Add the OrderSum -> and step out of my iteration, because
> the compared OrderNumbers are equal.
> ...
>
> But this proces will only work if XSLT is able to step out of
> (recursion or for each-loops)
XSLT cannot step out of for-each loops. When you construct the loop,
you must select the right pieces. For example:
<xsl:for-each select="preceding::oder"/>
Recursion can exit; in fact, if it doesn’t, you will have a very large
problem.
<xsl:template ...>
<xsl:param name="subtotal" select="0"/>
<xsl:choose>
<xsl:when test="no-more-to-do()">
<xsl:value-of select="$subtotal"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template...>
<xsl:with-param name="subtotal"
select="$subtotal + $this-one"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Keep your recursive structures tail-recursive, and many processors will
optimize them into a more procedural execution
~Chris
--
Chris Maden, text nerd <URL: http://crism.maden.org/ >
“All I ask of living is to have no chains on me,
And all I ask of dying is to go naturally.” — Laura Nyro
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]