It looks like your input data has a blank cell somewhere, which you are
trying to convert to a number.
Since you're using XSLT 2.0, I would recommend (a) using functions rather
than named templates, and (b) declaring the types of your variables and
parameters (for example as="xs:integer"). This makes this kind of user error
much easier to diagnose.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Byomkesh [mailto:bkesh(_at_)eztechgroup(_dot_)net]
Sent: 27 June 2006 08:12
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: gandhi(_dot_)mukul(_at_)gmail(_dot_)com
Subject: Re: [xsl] How count the Table cell (Cals Table) using XSL
Hi Mukul,
Thanks for your help. But its showing validation Error
<!---
Validation error
FORG0001: Cannot convert string "" to a double
Transformation failed: Run-time errors were reported
-->
I have using Saxon 8.7.3j. I did not understand this error.
Please Sorry again i am disturb you.
Now what can i do?
Thanks
Byomkesh
------------------------------------------------
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(_at_)eztechgroup(_dot_)net> wrote:
Dear All,
I have one xml file. I want count cell and divide percentage in
between
cell
(through XSL). Please any one help me.
XML File
-------------
<table border="0" cellspacing="0" cellpadding="1"
width="90%"> <thead>
<tr> <th valign="top" colspan="3">Table 1.1 802.11b
Channels</b></th>
</tr> <tr> <th>Channel Number</th> <th>Center Frequency (in
GHz)</th>
<th>USA</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2.412</td>
<td>✓</td> </tr> </tbody> </table>
I want OutPut
-----------------
<table>
<table.html frame="void" width="100%" rules="groups" align="left">
<colgroup> <col width="50%"/> <col width="30%"/> <col width="20%"/>
</colgroup>
<!-- Rest of the taging as it is -->
<thead>
<tr>
<th valign="top" colspan="3">Table 1.1 802.11b
Channels</b></th> </tr>
<tr> <th>Channel Number</th> <th>Center Frequency (in GHz)</th>
<th>USA</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2.412</td>
<td>✓</td> </tr> </tbody> </table>
Regards,
Byomkesh
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--