Subject: RE: [xsl] FW: xsl code to create tables of different number columns and rows From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Fri, 20 May 2005 15:57:08 +0000 |
columns, and in the second table 2. Throughout the book there can be a number of tables with different amount of columns/rows. Thus, I have to create a template that can interpret the cols="?" attribute and for each instance create a table with that amount of columns.
I am not good (yet) with xml or html. If I create an html table first, how do I then apply the tgroup/@cols to that?
<data> <table> <tgroup cols="3"> <colspec colname="col1"/> <colspec colname="col2"/> <colspec colname="col3"/> <tbody> <row> <entry>column1rowa</entry> <entry>column2rowa</entry> <entry>column3rowa</entry> </row> <row> <entry>column1rowb</entry> <entry>column2rowb</entry> <entry>column3rowb</entry> </row> </tbody> </tgroup> </table> <table> <tgroup cols="2"> <colspec colname="col1"/> <colspec colname="col2"/> <tbody> <row> <entry>column1rowa</entry> <entry>column2rowa</entry> </row> <row> <entry>column1rowb</entry> <entry>column2rowb</entry> </row> <row> <entry>column1rowc</entry> <entry>column2rowc</entry> </row> </tbody> </tgroup> </table> </data>
<xsl:template match="/"> <data> <xsl:apply-templates select="data/table"/> </data> </xsl:template>
<xsl:template match="table"> <table> <tr> <xsl:apply-templates select="tgroup/colspec"/> </tr> <xsl:apply-templates select="tgroup/tbody/row"/> </table> </xsl:template>
<xsl:template match="row"> <tr> <xsl:apply-templates select="entry"/> </tr> </xsl:template>
<xsl:template match="colspec"> <th><xsl:value-of select="@colname"/></th> </xsl:template>
<xsl:template match="entry"> <td><xsl:value-of select="."/></td> </xsl:template>
<?xml version="1.0" encoding="UTF-8"?> <data> <table> <tr> <th>col1</th> <th>col2</th> <th>col3</th> </tr> <tr> <td>column1rowa</td> <td>column2rowa</td> <td>column3rowa</td> </tr> <tr> <td>column1rowb</td> <td>column2rowb</td> <td>column3rowb</td> </tr> </table> <table> <tr> <th>col1</th> <th>col2</th> </tr> <tr> <td>column1rowa</td> <td>column2rowa</td> </tr> <tr> <td>column1rowb</td> <td>column2rowb</td> </tr> <tr> <td>column1rowc</td> <td>column2rowc</td> </tr> </table> </data>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] FW: xsl code to create ta, Martie Kruger | Thread | [xsl] multiple node values not bein, Rahil |
Re: [xsl] numbering/count(), Wendell Piez | Date | Re: [xsl] Functions Returning Nodes, Alan |
Month |