[xsl] Conditional counting

Subject: [xsl] Conditional counting
From: "Hunsberger, Peter" <Peter.Hunsberger@xxxxxxxxxx>
Date: Thu, 11 Oct 2001 13:53:11 -0500
I've got an XSLt running under LotusXSLt (Xalan) that conditionally calls
two different extensions:

    <table border="1">
        <xsl:if test="$gunk = 'x''">
            <xsl:apply-templates select="myExt.method1(*)" mode="x" />
        </xsl:if>
        <xsl:if test="$gunk != 'x'">
	<xsl:apply-templates select="myExt.method2(*)" mode="x"/>

        </xsl:if>
    </table>
    <xsl:value-of select="count(tr)"/> rows generated.

The returned results will include a varying number of <tr> tags (table rows)
independent of the passed XML  I'd like to have the count reflect the number
of tr tags returned from the extensions. As it is, the count is going to
reflect the number of <tr> tags in the input XML (zero in our case). The
child template simply resembles something like:

<xsl:template match="row" mode="x">
    <tr>
        <xsl:apply-templates select="*" mode="x"/>
    </tr>
</xsl:template>

I've tried a couple of differing approaches, in particular with placing the
extension results into a variable and then parsing the variable and counting
the tr elements in the variable, but so far no go.

Peter Hunsberger





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread