I have got this table in xml format below, where the tcols trows and ccols crows attributes all specify number of table columns, number of table rows, table cell colspans and table cell rowspans. Now I had the XSL to convert this xml table to a standard html table working until I came across the table cell rowspan (crows) greater than one. Attached is my XSL as well, any suggestions on this, as I know that my code doesn't accomodate rowspans??
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<TABELLA data_mod="2008-10-30 12:20:59" id="2899" locale="it_IT" colonne="3" righe="2"
colonna_1="33%" colonna_2="33%" colonna_3="33%">
<grown>
<TAB_2899>
<story>
<Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table"
aid:trows="3" aid:tcols="2" summary="NOCHANGE">
<Cell aid:table="cell" aid:crows="2" aid:ccols="1" aid:ccolwidth="184"
larghezza="33%">
row 1 col 1
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="184"
larghezza="33%">
row 1 col 2
</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="184"
larghezza="33%">row 2 col 2</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="184"
larghezza="33%">row 2 col 2</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="184"
larghezza="33%">row 2 col 2</Cell>
</Table>
</story>
</TAB_2899>
</grown>
</TABELLA>
</Root>
XSL code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
version="2.0">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title></head>
<body>
<xsl:for-each select="Root/TABELLA">
<xsl:variable name="numberofrows" select="grown/*/story/Table/attribute::aid:trows"></xsl:variable>
<xsl:variable name="numberofcols" select="grown/*/story/Table/attribute::aid:tcols"></xsl:variable>
<table>
<xsl:call-template name="output">
<xsl:with-param name="numberofrows" select="$numberofrows"></xsl:with-param>
<xsl:with-param name="numberofcols" select="$numberofcols"></xsl:with-param>
<xsl:with-param name="Table" select="grown/*/story/Table"></xsl:with-param>
<xsl:with-param name="counter" select="1"></xsl:with-param>
</xsl:call-template>
</table>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template name="output">
<xsl:param name="numberofrows"></xsl:param>
<xsl:param name="numberofcols"></xsl:param>
<xsl:param name="Table"></xsl:param>
<xsl:param name="counter"></xsl:param>
<xsl:choose>
<xsl:when test="$counter <= $numberofrows">
<tr>
<xsl:choose>
<xsl:when test="$counter = 1">
<!--this is the header row in each table-->
<xsl:attribute name="bgcolor">blue</xsl:attribute>
</xsl:when>
<xsl:when test="$counter > 1">
<!--this are the other rows in each table-->
<xsl:attribute name="bgcolor">red</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:for-each select="$Table/Cell[
sum(preceding-sibling::Cell/attribute::aid:ccols) < ($numberofcols * $counter) and
sum(preceding-sibling::Cell/attribute::aid:ccols) >= ($numberofcols * ($counter - 1)) ]">
<td>
<xsl:if test="@aid:ccols > 1">
<xsl:attribute name="colspan" select="@aid:ccols"></xsl:attribute>
</xsl:if>
<xsl:if test="@aid:crows > 1">
<xsl:attribute name="rowspan" select="@aid:crows"></xsl:attribute>
</xsl:if>
<xsl:apply-templates></xsl:apply-templates>
</td>
</xsl:for-each>
</tr>
<xsl:call-template name="output">
<xsl:with-param name="numberofrows" select="$numberofrows"></xsl:with-param>
<xsl:with-param name="numberofcols" select="$numberofcols"></xsl:with-param>
<xsl:with-param name="Table" select="$Table"></xsl:with-param>
<xsl:with-param name="counter" select="$counter + 1"></xsl:with-param>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="_B">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="_centro">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="img_html">
<img>
<xsl:attribute name="src" select="@href"></xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>
I have got the number of rows right its just the rowspan. Please enlighten me!