xsl-list
[Top] [All Lists]

AW: how to get node with maximum child nodes ??

2003-08-28 11:21:30
Hi Dipesh,

you have 2 <CLASS NAME="Client_Agent> elements in your XML.
For each, you find the maximum ATTRIBUTE element count in OBJECT elements.
So you get 2 values.

If you want to get the overall maximum, do:

<xsl:for-each select="//CLASS[normalize-space(@NAME)='Client_Agent']/OBJECT">
        <xsl:sort select="count(ATTRIBUTE)" order="descending"/>
                <xsl:if test="position()=1">
                        <xsl:value-of select="generate-id(.)"/>
                </xsl:if>
</xsl:for-each>


Regards,
Markus
__________________________
Markus Abt
Comet Computer GmbH
http://www.comet.de


----------
Von:    Dipesh Khakhkhar
Gesendet:       Donnerstag, 28. August 2003 17:38
An:     xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff:        [xsl] how to get node with maximum child nodes ??

[...]
<xsl:for-each select="//CLASS">
        <xsl:choose>
                <xsl:when test="normalize-space(@NAME)='Client_Agent'">
                        <xsl:for-each select="OBJECT">
                                <xsl:sort select="count(ATTRIBUTE)" 
order="descending"/>
                                        <xsl:if test="position()=1">
                                                <xsl:value-of 
select="generate-id(.)"/>
                                        </xsl:if>
                        </xsl:for-each>
                </xsl:when>
        </xsl:choose>
</xsl:for-each>
[...]


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



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