xsl-list
[Top] [All Lists]

Re: Max count?

2005-07-19 03:58:59
Hi,

Tempore 12:31:55, die 07/19/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Dan Powderhill <dan(_dot_)powderhill(_at_)brainjuicer(_dot_)com>:

I need to retrieve the maximum number of line nodes contained by a
column node within the datanode node. So for the example xml it would be
3, as column 2 has three line nodes.

There are various method to deal with this problem. I enlist some of them:
extension function
recursive templates e.g. http://www.topxml.com/xsltStylesheets/xslt_recursion.asp

here's a quick solution:
<xsl:template match="datanode">
max:
        <xsl:for-each select="column">
                <xsl:sort data-type="number" select="count(line)"/>
<xsl:if test="position()=last()"><xsl:value-of select="count(line)"/></xsl:if>
        </xsl:for-each>
</xsl:template>


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
"Η αλήθεια και το λάδι πάντα βγαίνουν από πάνω"

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>