PDA

View Full Version : XSL - five column table


James_Sheppard
11-25-2005, 10:24 AM
Hello

I have no background knowledge of XSL and I am creating an XSL structure for a document. I have the XML data along with a Schema, but the XSL part is where I am stuck.

I need to have a five column table (see attachment of the paper document). The HTML file needs to look similar to the attached paper document, but I do not know how to set up the five columns and the rows etc.

If anyone on here can assist me in creating the five column table (or something close to the paper document) I should then be able to insert the xsl:template match and templates select statements into the table created.

Any help would be much appreciated on this topic.

Many Thanks

James

http://img291.imageshack.us/img291/2584/mucataloguewithcolumns1dz.th.jpg (http://img291.imageshack.us/my.php?image=mucataloguewithcolumns1dz.jpg)

bphein1980
11-26-2005, 04:11 AM
Here is some code I use to display pictures on a website. It resticts a table to to 'x' amount of columns.

Maybe you can start with it... Just change the param "colMax" to how many columns you want to restrict the table to.

If you set it at 5... your table would be like this...

Row 1 - 1,2,3,4,5
Row 2 - 6,7,8,9,10
Row 3 - 11,12,13,14,15
etc

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:param name="colMax">6</xsl:param>
<xsl:template match="/">

<html>
<body>
<h1>Pictures</h1>
<table border="0" cellspacing="0">
<xsl:for-each select="//picture[position() mod $colMax = 1]">
<tr>
<xsl:for-each select=" . | following-sibling::*[position() &lt; $colMax]">
<td>
*******CELL DATA GOES HERE********
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>

</xsl:template>
</xsl:stylesheet>

You can see the section of the website that uses the code if you go to http://www.bigirongym.com and click on any link in the picture and video section on the right hand side.

Hope it helps.

James_Sheppard
11-26-2005, 09:38 AM
Thank You For This:thumbsup:

I will attempt this today

James_Sheppard
12-01-2005, 02:07 PM
Hi

I had a go using the code above, and a mate of mine said it wouldn't work well for my document.

I've then on advice on one of my mates created the tables I needed in DreamWeaver. The final result should hopefully look like this.

Now I've copied the HTML code into the XSL file and added all the xsl:template match and select, yet I am still when viewing the document seeing my old version of the XSL. When running the XSL through JEdit, and with the prompts on, its telling me I have to close <tr> <td> <table>, even thoe everything is closed.

I have attached the XSL code, if someone could point out to me my error of my ways I wud very much appreciate it.

Best Wishes

John