Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2012, 05:07 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default colwidth

Hi,

I have doubt in convert xml to html. I don't know to fix column width as per xml value.

it will take the table column width based on text, but i need column value from colwidth attribute. how to fix this problem in XSLT.



<table frame="none" pgwide="1">
<tgroup cols="4" colsep="0" rowsep="0">
<colspec colname="1" colnum="1" colsep="0" colwidth="20%" rowsep="0"/>
<colspec colname="2" colnum="2" colsep="0" colwidth="25%" rowsep="0"/>
<colspec colname="3" colnum="3" colsep="0" colwidth="30%" rowsep="0"/>
<colspec colname="4" colnum="4" colsep="0" colwidth="25%" rowsep="0"/>
<tbody valign="top">
<row>
<entry colname="1" colsep="0" rowsep="0" align="center">&#x0028;1&#x0029;<nl/><emph typestyle="it">No.</emph></entry>
<entry colname="2" colsep="0" rowsep="0" align="center">&#x0028;2&#x0029;<nl/><emph typestyle="it">Name of Housing Developer</emph></entry>
<entry colname="3" colsep="0" rowsep="0" align="center">&#x0028;3&#x0029;<nl/><emph typestyle="it">House</emph></entry>
<entry colname="4" colsep="0" rowsep="0" align="center">&#x0028;4&#x0029;<nl/><emph typestyle="it">Area</emph></entry>
</row>
</tbody>
</tgroup>
</table>

Regards,
Rockbal
 
Old January 27th, 2012, 05:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Is what you have shown us the input or the output? To help you write a transformation, we need to see both, and to understand how they relate.

Do you actually know what HTML you want to generate?

If you do, then please tell us.

If you don't, then you have an HTML question rather than an XSLT question, and you are asking on the wrong forum.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 27th, 2012, 09:25 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default colspec

Hi,

Sorry for previous post.

The below coding my xml and html. i need to transfer xml to html by using xslt. The xsl coding i need for convert xml to html.



XML Coding
<table frame="none" pgwide="1">
<tgroup cols="4" colsep="0" rowsep="0">
<colspec colname="1" colnum="1" colsep="0" colwidth="40*" rowsep="0"/>
<colspec colname="2" colnum="2" colsep="0" colwidth="20*" rowsep="0" align="right"/>
<colspec colname="3" colnum="3" colsep="0" colwidth="20*" rowsep="0" align="right"/>
<colspec colname="4" colnum="4" colsep="0" colwidth="20*" rowsep="0" align="left"/>
<tbody valign="top">
<row>
<entry colname="1" colsep="0" rowsep="0" align="center"><emph typestyle="it">Value of Claim or Counterclaim</emph></entry>
<entry colname="2" colsep="0" rowsep="0" align="center"><emph typestyle="it">Suing</emph></entry>
<entry colname="3" colsep="0" rowsep="0" align="center"><emph typestyle="it">Defending</emph></entry>
<entry colname="4" colsep="0" rowsep="0" align="center"><emph typestyle="it">Advocacy</emph></entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">&#x201C;Exceeds 25,000 but not 27,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">650</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">650</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">2,550</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 27,500 but not 30,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">675</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">675</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">2,650</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 30,000 but not 32,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">700</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">700</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">2,750</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 32,500 but not 35,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">725</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">725</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">2,850</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 35,000 but not 37,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">750</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">750</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">2,950</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 37,500 but not 40,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">775</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">775</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,050</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 40,000 but not 42,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">800</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">800</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,150</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 42,500 but not 45,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">825</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">825</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,250</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 45,000 but not 47,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">850</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">850</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,350</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 47,500 but not 50,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">875</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">875</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,450</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 50,000 but not 52,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">900</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">900</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,550</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 52,500 but not 55,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">925</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">925</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,650</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 55,000 but not 57,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">950</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">950</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,750</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 57,500 but not 60,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">975</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">975</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,850</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 60,000 but not 62,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,000</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,000</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">3,950</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 62,500 but not 65,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,025</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,025</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,050</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 65,000 but not 67,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,050</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,050</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,150</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 67,500 but not 70,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,075</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,075</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,250</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 70,000 but not 72,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,100</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,100</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,350</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 72,500 but not 75,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,125</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,125</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,450</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 75,000 but not 77,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,150</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,150</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,550</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 77,500 but not 80,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,175</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,175</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,650</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 80,000 but not 82,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,200</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,200</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,750</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 82,500 but not 85,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,225</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,225</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,850</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 85,000 but not 87,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,250</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,250</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">4,950</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 87,500 but not 90,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,275</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,275</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">5,050</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 90,000 but not 92,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,300</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,300</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">5,150</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 92,500 but not 95,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,325</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,325</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">5,250</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 95,000 but not 97,500</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,350</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,350</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">5,350</entry>
</row>
<row>
<entry colname="1" colsep="0" rowsep="0">Exceeds 97,500 but not 100,000</entry>
<entry colname="2" colsep="0" rowsep="0" align="right">1,375</entry>
<entry colname="3" colsep="0" rowsep="0" align="right">1,375</entry>
<entry colname="4" colsep="0" rowsep="0" align="right">5,450&#x201D;.</entry>
</row>
</tbody>
</tgroup>
</table>


HTML Coding

<table bgcolor="#ffdecc" border="1" cellpadding="5" width="80%" align="center" cellspacing="0" style="0px 0px 0px 0px solid #000000;">
<tbody valign="top">
<tr>
<td align="center" style="width:40%"><span style="color:red"><i>Value of Claim or Counterclaim</i></span></td>
<td align="center" style="width:20%"><span style="color:red"><i>Suing</i></span></td>
<td align="center" style="width:20%"><span style="color:red"><i>Defending</i></span></td>
<td align="center" style="width:20%"><span style="color:red"><i>Advocacy</i></span></td>
</tr>
<tr>
<td">“Exceeds 25,000 but not 27,500</td>
<td align="right">650</td>
<td align="right">650</td>
<td align="right">2,550</td>
</tr>
<tr>
<td>Exceeds 27,500 but not 30,000</td>
<td align="right">675</td>
<td align="right">675</td>
<td align="right">2,650</td>
</tr>
<tr>
<td>Exceeds 30,000 but not 32,500</td>
<td align="right">700</td>
<td align="right">700</td>
<td align="right">2,750</td>
</tr>
<tr>
<td>Exceeds 32,500 but not 35,000</td>
<td align="right">725</td>
<td align="right">725</td>
<td align="right">2,850</td>
</tr>
<tr>
<td>Exceeds 35,000 but not 37,500</td>
<td align="right">750</td>
<td align="right">750</td>
<td align="right">2,950</td>
</tr>
<tr>
<td>Exceeds 37,500 but not 40,000</td>
<td align="right">775</td>
<td align="right">775</td>
<td align="right">3,050</td>
</tr>
<tr>
<td>Exceeds 40,000 but not 42,500</td>
<td align="right">800</td>
<td align="right">800</td>
<td align="right">3,150</td>
</tr>
<tr>
<td>Exceeds 42,500 but not 45,000</td>
<td align="right">825</td>
<td align="right">825</td>
<td align="right">3,250</td>
</tr>
<tr>
<td>Exceeds 45,000 but not 47,500</td>
<td align="right">850</td>
<td align="right">850</td>
<td align="right">3,350</td>
</tr>
<tr>
<td>Exceeds 47,500 but not 50,000</td>
<td align="right">875</td>
<td align="right">875</td>
<td align="right">3,450</td>
</tr>
<tr>
<td>Exceeds 50,000 but not 52,500</td>
<td align="right">900</td>
<td align="right">900</td>
<td align="right">3,550</td>
</tr>
<tr>
<td>Exceeds 52,500 but not 55,000</td>
<td align="right">925</td>
<td align="right">925</td>
<td align="right">3,650</td>
</tr>
<tr>
<td>Exceeds 55,000 but not 57,500</td>
<td align="right">950</td>
<td align="right">950</td>
<td align="right">3,750</td>
</tr>
<tr>
<td>Exceeds 57,500 but not 60,000</td>
<td align="right">975</td>
<td align="right">975</td>
<td align="right">3,850</td>
</tr>
<tr>
<td>Exceeds 60,000 but not 62,500</td>
<td align="right">1,000</td>
<td align="right">1,000</td>
<td align="right">3,950</td>
</tr>
<tr>
<td>Exceeds 62,500 but not 65,000</td>
<td align="right">1,025</td>
<td align="right">1,025</td>
<td align="right">4,050</td>
</tr>
<tr>
<td>Exceeds 65,000 but not 67,500</td>
<td align="right">1,050</td>
<td align="right">1,050</td>
<td align="right">4,150</td>
</tr>
<tr>
<td>Exceeds 67,500 but not 70,000</td>
<td align="right">1,075</td>
<td align="right">1,075</td>
<td align="right">4,250</td>
</tr>
<tr>
<td>Exceeds 70,000 but not 72,500</td>
<td align="right">1,100</td>
<td align="right">1,100</td>
<td align="right">4,350</td>
</tr>
<tr>
<td>Exceeds 72,500 but not 75,000</td>
<td align="right">1,125</td>
<td align="right">1,125</td>
<td align="right">4,450</td>
</tr>
<tr>
<td>Exceeds 75,000 but not 77,500</td>
<td align="right">1,150</td>
<td align="right">1,150</td>
<td align="right">4,550</td>
</tr>
<tr>
<td>Exceeds 77,500 but not 80,000</td>
<td align="right">1,175</td>
<td align="right">1,175</td>
<td align="right">4,650</td>
</tr>
<tr>
<td>Exceeds 80,000 but not 82,500</td>
<td align="right">1,200</td>
<td align="right">1,200</td>
<td align="right">4,750</td>
</tr>
<tr>
<td>Exceeds 82,500 but not 85,000</td>
<td align="right">1,225</td>
<td align="right">1,225</td>
<td align="right">4,850</td>
</tr>
<tr>
<td>Exceeds 85,000 but not 87,500</td>
<td align="right">1,250</td>
<td align="right">1,250</td>
<td align="right">4,950</td>
</tr>
<tr>
<td>Exceeds 87,500 but not 90,000</td>
<td align="right">1,275</td>
<td align="right">1,275</td>
<td align="right">5,050</td>
</tr>
<tr>
<td>Exceeds 90,000 but not 92,500</td>
<td align="right">1,300</td>
<td align="right">1,300</td>
<td align="right">5,150</td>
</tr>
<tr>
<td>Exceeds 92,500 but not 95,000</td>
<td align="right">1,325</td>
<td align="right">1,325</td>
<td align="right">5,250</td>
</tr>
<tr>
<td>Exceeds 95,000 but not 97,500</td>
<td align="right">1,350</td>
<td align="right">1,350</td>
<td align="right">5,350</td>
</tr>
<tr>
<td>Exceeds 97,500 but not 100,000</td>
<td align="right">1,375</td>
<td align="right">1,375</td>
<td align="right">5,450”.</td>
</tr>
</tbody>
</table>



Kindly advise to me.


Thanks and Rockbal
 
Old January 27th, 2012, 10:40 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Next time you make a posting, please try to keep the samples smaller. You only need to show enough detail for people to understand the essence of the problem. We don't need to see all 30 rows in your table.

You haven't said anything about why you are finding this difficult, so it's hard to know what you need to learn. Basically, when you are creating the column headers, you need something like:

Code:
<xsl:template match="table/row[1]/entry">
  <td align="center" style="width:{translate(ancestor::tgroup/colspec[@colname=current()/@colname]/@colwidth, '*', '%')}"><span style="color:red"><i><xsl:value-of select="."/></i></span></td>
</xsl:template>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.