This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Conditional counting
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Conditional counting
- From: "Hunsberger, Peter" <Peter dot Hunsberger at stjude dot org>
- Date: Thu, 11 Oct 2001 13:53:11 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
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