This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
quick table layout problem
- From: "Andrew Welch" <andrew at thebristoldirectory dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 7 Jan 2002 11:55:26 -0000
- Subject: [xsl] quick table layout problem
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi all,
As a quick aside to the deep discussions currently taking place, please can
someone help me with this probably-very-simple problem:
Below is the xml for a table. Its a huge amount of code for a very small
amount of data... but thats beside the point (I have no control over the
input) What I need is the table to be drawn using the widths specified by
the colwidth attributes of the colspec.
I can draw the table ok, but when I try to include the column widths I begin
to struggle. This is the xsl Im using, with the xml at the end.
Many thanks in advance
cheers
andrew
<xsl:template match="table">
<table border="1">
<xsl:call-template name="tableHead"/>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template name="tableHead">
<xsl:for-each select="//table//thead//entry">
<th>
<xsl:value-of select="."/>
</th>
</xsl:for-each>
</xsl:template>
<xsl:template match="//tbody/row[position() mod 2 = 0]">
<tr>
<xsl:for-each select="entry">
<td class="table_row_color">
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="//tbody/row[position() mod 2 = 1]">
<tr>
<xsl:for-each select="entry">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<table frame="ALL" orient="PORT">
<tgroup cols="6">
<colspec colnum="1" colname="COL1" colwidth="113*"
colsep="1" rowsep="1">
<colspec colnum="2" colname="COL2" colwidth="78*"
colsep="1" rowsep="1">
<colspec colnum="3" colname="COL3" colwidth="78*"
colsep="1" rowsep="1">
<colspec colnum="4" colname="COL4"
colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="5" colname="COL5"
colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="6" colname="COL6"
colwidth="78*" colsep="1" rowsep="1">
<thead>
<colspec colnum="1" colname="COL1"
colwidth="113*" colsep="1" rowsep="1">
<colspec colnum="2"
colname="COL2" colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="3"
colname="COL3" colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="4"
colname="COL4" colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="5"
colname="COL5" colwidth="78*" colsep="1" rowsep="1">
<colspec colnum="6"
colname="COL6" colwidth="78*" colsep="1" rowsep="1">
<row>
<entry
colname="COL1" colsep="1" rowsep="1">Nominal, UN Thread, Size</entry>
<entry
colname="COL2" colsep="1" rowsep="1">Nm</entry>
<entry
colname="COL3" colsep="1" rowsep="1">lbf in</entry>
<entry
colname="COL4" colsep="1" rowsep="1">Nominal, BSP Thread</entry>
<entry
colname="COL5" colsep="1" rowsep="1">Nm</entry>
<entry
colname="COL6" colsep="1" rowsep="1">lbf in</entry>
</row>
</colspec>
</colspec>
</colspec>
</colspec>
</colspec>
</colspec>
</thead>
<tbody>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.4375-20 7/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">16.5</entry>
<entry colname="COL3"
colsep="1" rowsep="1">145</entry>
<entry colname="COL4"
colsep="1" rowsep="1">1/8 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">12.5</entry>
<entry colname="COL6"
colsep="1" rowsep="1">110</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.5000-20 1/2 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">19</entry>
<entry colname="COL3"
colsep="1" rowsep="1">170</entry>
<entry colname="COL4"
colsep="1" rowsep="1">1/4 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">23</entry>
<entry colname="COL6"
colsep="1" rowsep="1">205</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.6250-18 5/8 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">24</entry>
<entry colname="COL3"
colsep="1" rowsep="1">215</entry>
<entry colname="COL4"
colsep="1" rowsep="1">3/8 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">29</entry>
<entry colname="COL6"
colsep="1" rowsep="1">260</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.6875-16 11/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">27</entry>
<entry colname="COL3"
colsep="1" rowsep="1">240</entry>
<entry colname="COL4"
colsep="1" rowsep="1">1/2 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">40</entry>
<entry colname="COL6"
colsep="1" rowsep="1">355</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.7500-16 3/4 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">30</entry>
<entry colname="COL3"
colsep="1" rowsep="1">265</entry>
<entry colname="COL4"
colsep="1" rowsep="1">5/8 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">44</entry>
<entry colname="COL6"
colsep="1" rowsep="1">390</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.8125-16 13/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">33</entry>
<entry colname="COL3"
colsep="1" rowsep="1">295</entry>
<entry colname="COL4"
colsep="1" rowsep="1">3/4 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">57</entry>
<entry colname="COL6"
colsep="1" rowsep="1">505</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">.8750-14 7/8 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">37</entry>
<entry colname="COL3"
colsep="1" rowsep="1">325</entry>
<entry colname="COL4"
colsep="1" rowsep="1">7/8 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">68</entry>
<entry colname="COL6"
colsep="1" rowsep="1">600</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">1.0625-12 1.1/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">47</entry>
<entry colname="COL3"
colsep="1" rowsep="1">420</entry>
<entry colname="COL4"
colsep="1" rowsep="1">1 in</entry>
<entry colname="COL5"
colsep="1" rowsep="1">80</entry>
<entry colname="COL6"
colsep="1" rowsep="1">708</entry>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">1.1875-12 1.3/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">56</entry>
<entry colname="COL3"
colsep="1" rowsep="1">500</entry>
<entry colname="COL4"
colsep="1" rowsep="1"/>
<entry colname="COL5"
colsep="1" rowsep="1"/>
<entry colname="COL6"
colsep="1" rowsep="1"/>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">1.3125-12 1.5/16 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">67</entry>
<entry colname="COL3"
colsep="1" rowsep="1">590</entry>
<entry colname="COL4"
colsep="1" rowsep="1"/>
<entry colname="COL5"
colsep="1" rowsep="1"/>
<entry colname="COL6"
colsep="1" rowsep="1"/>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">1.6250-12 1.5/8 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">99</entry>
<entry colname="COL3"
colsep="1" rowsep="1">876</entry>
<entry colname="COL4"
colsep="1" rowsep="1"/>
<entry colname="COL5"
colsep="1" rowsep="1"/>
<entry colname="COL6"
colsep="1" rowsep="1"/>
</row>
<row>
<entry colname="COL1"
colsep="1" rowsep="1">1.8750-12 1.7/8 in</entry>
<entry colname="COL2"
colsep="1" rowsep="1">135</entry>
<entry colname="COL3"
colsep="1" rowsep="1">1620</entry>
<entry colname="COL4"
colsep="1" rowsep="1"/>
<entry colname="COL5"
colsep="1" rowsep="1"/>
<entry colname="COL6"
colsep="1" rowsep="1"/>
</row>
</tbody>
</colspec>
</colspec>
</colspec>
</colspec>
</colspec>
</colspec>
</tgroup>
</table>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list