[Home] [By Thread] [By Date] [Recent Entries]
Hi Byomkesh, This is easier in XSLT 2.0. Below is the XSLT 2.0 solution (tested with Saxon 8.7.3J): <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/table">
<table>
<table.html frame="void" width="100%" rules="groups" align="left" />
<xsl:variable name="rtf">
<xsl:call-template name="FindMaxStringLength">
<xsl:with-param name="n" select="count(//tr/td)" />
</xsl:call-template>
</xsl:variable>
<colgroup>
<xsl:for-each select="$rtf/x">
<col width="{format-number(((. div (sum(../*))) * 100),
'##.##')}%"/>
</xsl:for-each>
</colgroup>
<xsl:copy-of select="*" />
</table>
</xsl:template> <xsl:template name="FindMaxStringLength">
<xsl:param name="n" /> <xsl:if test="$n > 0">
<x>
<xsl:for-each select="//tr[2]/th[$n] | //tr/td[$n]">
<xsl:sort select="string-length(.)" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="string-length(.)" />
</xsl:if >
</xsl:for-each>
</x>
<xsl:call-template name="FindMaxStringLength">
<xsl:with-param name="n" select="$n - 1" />
</xsl:call-template>
</xsl:if></xsl:template> </xsl:stylesheet> The stylesheet dynamically finds the column percentages depending on the amount of content in table cells across the whole Table. The table.html tag is not clear to me. I have done something with it. Hope you can tinker the stylesheet. Regards, Mukul On 6/24/06, Byomkesh <bkesh@xxxxxxxxxxxxxxx> wrote: Dear All,
|

Cart



