Subject: Re: [xsl] How count the Table cell (Cals Table) using XSL From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Tue, 27 Jun 2006 17:15:08 +0530 |
Hi Byomkesh, There are some problems in your code. Following corrections are required:
<xsl:variable name="rtf"> <xsl:call-template name="FindMaxStringLength"> <xsl:with-param name="n" select="count(//tr[3]/td)" /> </xsl:call-template> </xsl:variable> (in <xsl:template match="table"> )
<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>
<colgroup> <col width="21.74%"/> <col width="36.96%"/> <col width="41.3%"/> </colgroup>
Regards, Mukul
Hi Mukul
This is my XML file ---------------------- <html> <body> <h1>FCC and IEEE Regulations</h1> <p>Table 1.3 shows the relative FCC and IEEE power output limits.</p> <table border="0" cellspacing="0" cellpadding="1" width="90%"> <thead> <tr> <th valign="top" colspan="3">Table 1.3 802.11a Power Output Limits</th></tr> <tr> <th valign="top"><b>Spectrum Range</b></th> <th valign="top"><b>FCC Limit</b></th> <th valign="top"><b>IEEE Limit</b></th></tr> </thead> <tbody> <tr><td valign="top">5.15 GHz–5.25 GHz</td> <td valign="top">5.15 GHz–5.25 GHz</td> <td valign="top">40 mW</td></tr> <tr><td valign="top">5.25 GHz–5.35 GHz</td> <td valign="top">200 mW</td> <td valign="top">250 mW</td></tr> <tr><td valign="top">5.725 GHz–5.825 GHz</td> <td valign="top">800 mW</td> <td valign="top">1,000 mW</td></tr> </tbody> </table> </body> </html>
XSL file -----------------
<xsl:transform xmlns:gale="http://www.gale.com/eBooks" xmlns:gale="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" version="1.1" exclude-result-prefixes="gale" extension-element-prefixes="saxon">
<xsl:param name="saxon.character.representation" select="decimal" /> <xsl:output saxon:character-representation="'entity;decimal'" method="xml" encoding="US-ASCII" indent="yes" />
<xsl:template match="/">
<document> <xsl:apply-templates select="html"/> </document> </xsl:template>
<xsl:template match="body">
<xsl:apply-templates/> </xsl:template>
<xsl:template match="h1"> <title><xsl:apply-templates/></title> </xsl:template>
<xsl:template match="p"> <xsl:element name="para"> <xsl:apply-templates/> </xsl:element> </xsl:template>
<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:template match="tr"> <xsl:text>
</xsl:text><tr> <xsl:apply-templates/> </tr> </xsl:template>
<xsl:template match="td"> <xsl:text>
</xsl:text><td> <xsl:apply-templates/> </td> </xsl:template>
<xsl:template match="th"> <xsl:text>
</xsl:text><th> <xsl:apply-templates/> </th> </xsl:template>
<xsl:template match="thead"> <xsl:text>
</xsl:text><thead> <xsl:apply-templates/> </thead> </xsl:template>
<xsl:template match="tbody"> <xsl:text>
</xsl:text><tbody> <xsl:apply-templates/> </tbody> </xsl:template> </xsl:transform>
Now Output --> -----------------
<?xml version="1.0" encoding="US-ASCII"?> <document>
<title>FCC and IEEE Regulations</title> <para>Table 1.3 shows the relative FCC and IEEE power output limits.</para> <table> <table.html frame="void" width="100%" rules="groups" align="left"/> <colgroup> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> <col width="NaN%"/> </colgroup> <thead> <tr> <th valign="top" colspan="3">Table 1.3 802.11a Power Output Limits</th> </tr> <tr> <th valign="top"> <b>Spectrum Range</b> </th> <th valign="top"> <b>FCC Limit</b> </th> <th valign="top"> <b>IEEE Limit</b> </th> </tr> </thead> <tbody> <tr> <td valign="top">5.15 GHz–5.25 GHz</td> <td valign="top">5.15 GHz–5.25 GHz</td> <td valign="top">40 mW</td> </tr> <tr> <td valign="top">5.25 GHz–5.35 GHz</td> <td valign="top">200 mW</td> <td valign="top">250 mW</td> </tr> <tr> <td valign="top">5.725 GHz–5.825 GHz</td> <td valign="top">800 mW</td> <td valign="top">1,000 mW</td> </tr> </tbody> </table>
</document>
Not convert to percentage and maximu <col width="?">
Thanks,
Byomkesh ----- Original Message ----- From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> To: "Byomkesh" <bkesh@xxxxxxxxxxxxxxx> Cc: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, June 27, 2006 1:13 PM Subject: Re: [xsl] How count the Table cell (Cals Table) using XSL
> Hi Byomkesh, > I am not getting the error you posted. > > XML is (I had to correct a well formdness error): > > <table border="0" cellspacing="0" cellpadding="1" width="90%"> > <thead> > <tr> > <th valign="top" colspan="3"><b>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> > > With the stylesheet I posted, I am getting output: > > java net.sf.saxon.Transform bk.xml bk.xsl > <?xml version="1.0" encoding="UTF-8"?> > <table> > <table.html frame="void" width="100%" rules="groups" align="left"/> > <colgroup> > <col width="7.14%"/> > <col width="59.52%"/> > <col width="33.33%"/> > </colgroup> > <thead> > <tr> > <th valign="top" colspan="3"> > <b>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>NB#C4</td> > </tr> > </tbody> > </table> > > I am using Saxon basic version. Are you using Saxon Schema Aware version? > > Regards, > Mukul > > On 6/27/06, Byomkesh <bkesh@xxxxxxxxxxxxxxx> wrote: > > 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How count the Table cell , Byomkesh | Thread | Re: [xsl] How Handle Html Heading T, Byomkesh |
Re: [xsl] Problem with str:tokenize, David Carlisle | Date | RE: [xsl] Transformation using xslt, Michael Kay |
Month |