Re: [xsl] Using xslt how can i find out a <tr> with greate3r number of td/th?

Subject: Re: [xsl] Using xslt how can i find out a <tr> with greate3r number of td/th?
From: "cking" <cking@xxxxxxxxxx>
Date: Fri, 17 Sep 2004 18:50:26 +0200
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="/*">
  <result>
   <xsl:apply-templates/>
  </result>
 </xsl:template>

 <xsl:template match="tr">
  <xsl:variable name="n" select="count(th|td)"/>
  <xsl:if test="not(../tr[count(th|td) > $n])">
   <max count="{$n}" index="{count(preceding-sibling::tr)+1}"/>
  </xsl:if>
 </xsl:template>

</xsl:stylesheet>

--- output:
,
<result>
   <max count="4" index="2"/>
</result>

(if there are more than 1 tr with max nr of th|td in the input, 
there will be more than 1 max in result output, too)

Cheers,
Anton Triest


Eldho George wrote:
> 
> Hai all
>  
> Using xslt how can i find out a <tr> with greate3r number of td/th? is it
> possible?
>  
> <tr>
> <td></td>
> <tr>
> <tr>
> <td></td>
> <td></td>
> <td></td>
> <td></td>
> </tr>
>  
> Here I want tr[2].Each time the structure is different.I want to take the
> <tr> with maximum number of <td>|<th>
>  
> Please help me
> Thanks in advance

Current Thread