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

AW: [xsl] how to get node with maximum child nodes ??


Subject: AW: [xsl] how to get node with maximum child nodes ??
From: Markus Abt <abt@xxxxxxxx>
Date: Thu, 28 Aug 2003 20:21:30 +0200

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@xxxxxxxxxxxxxxxxxxxxxx
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



Current Thread