[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: RE: [xsl] Alternatives to "Stopping" a for-each


Subject: RE: RE: [xsl] Alternatives to "Stopping" a for-each
From: <trond.huso@xxxxxx>
Date: Mon, 18 Feb 2013 07:22:35 +0000

Just in case someone else is in the same situation. This became my solution.
Thanks for valuable feedback to Michael and Serhiy.

<xsl:template name="getRanking">
        <xsl:param name="structure"/>
        <xsl:param name="counter"/>
        <xsl:param name="winner"/>

        <xsl:choose>
            <xsl:when test="$structure/Start[Ranking=$counter]/StartNo =
$winner">
                <xsl:value-of
select="$structure/Start[Ranking=$counter]/StartNo"/>
                <!--<xsl:text> </xsl:text>-->
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of
select="$structure/Start[Ranking=$counter]/StartNo"/>
                <xsl:text>-</xsl:text>
                <xsl:call-template name="getRanking">
                    <xsl:with-param name="structure" select="$structure"/>
                    <xsl:with-param name="counter" select="$counter + 1"/>
                    <xsl:with-param name="winner" select="$winner"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

Called like this:

<xsl:for-each select="Legs[@ResultsComplete='true']/Leg">

                    <xsl:value-of select="LegNo" />
                    <xsl:text>. avd: </xsl:text>

                    <xsl:call-template name="getRanking">
                        <xsl:with-param name="structure" select="Starts" />
                        <xsl:with-param name="counter" select="1" />
                        <xsl:with-param name="winner"
select="Winners/Winner/@StartNo" />

                    </xsl:call-template>

....
</xsl:for-each>


Trond


Current Thread