Subject: [xsl] determine maximum columns in table From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx> Date: Wed, 8 Oct 2008 13:20:58 +1300 |
I have input XML which includes tables of the following form: table - tt? - th? - tr* - td* - tb - tr* - td* - tf? - tr* - td* The requirement is to determine the maximum number of columns in the table. The number of columns spanned by a cell (td) element is provided in a colspan attribute, and if no colspan attribute exists the cell of course occupies one column. The following XSL template is defective inasmuch as it ignores colspan. The context node when this template is called is <table>. <!-- output maximum number of columns in any child row --> <xsl:template name="counttablecols"> <xsl:for-each select="*/tr"> <xsl:sort select="count(td)" order="descending" /> <xsl:if test="position() = 1"> <xsl:value-of select="count(td)" /> </xsl:if> </xsl:for-each> </xsl:template> I can't see how to modify the sort so that I count 1 for each non-colspanned td and the appropriate value for each td which does have a colspan attribute. Is it possible? An XSL 1.0 solution is preferred. Cheers Trevor
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to substitute a porti, Paul | Thread | Re: [xsl] determine maximum columns, G. Ken Holman |
Re: [xsl] How to substitute a porti, Syd Bauman | Date | Re: [xsl] determine maximum columns, G. Ken Holman |
Month |