[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Splitting merged XHTML cells

Subject: Splitting merged XHTML cells
From: "honyk" <honyk@xxxxxxxxx>
Date: Sun, 19 Dec 2004 14:35:29 +0100
select xhtml
I need to transform xhtml table to special output. Its syntax for merging
cells is similar to xhtml, but it requires to specify every cell even if it
is merged:

<tr>
  <td rowspan="2" colspan="2">A1:B2</td>
  <td>C1</td>
</tr>
<tr>
  <td>C2</td>
</tr>

<RowStart:><CellStart:2,2>A1:B1<CellEnd:><CellStart:1,1><CellEnd:><CellStart
:1,1>C1<CellEnd:><RowEnd:>
<RowStart:><CellStart:1,1><CellEnd:><CellStart:1,1><CellEnd:><CellStart:1,1>
C2<CellEnd:><RowEnd:>

For colspan I use recursion and it works fine, but for rowspan and
combination with colspan I have no idea:

<xsl:template match="xhtml:table">
  ...
  <xsl:for-each select="xhtml:tr">
    <xsl:text>&lt;RowStart:&gt;</xsl:text>
    <xsl:for-each select="./xhtml:td">
      <xsl:call-template name="addTableCells">
      <xsl:with-param name="numRows" select="./@rowspan" />
      <xsl:with-param name="numCols" select="./@colspan" />
      <xsl:with-param name="content" select="." />
      </xsl:call-template>
    </xsl:for-each>
    <xsl:text>&lt;RowEnd:&gt;</xsl:text>
  </xsl:for-each>
</xsl:template>

<xsl:template name="addTableCells">
  <xsl:param name="numRows" select="1" />
  <xsl:param name="numCols" select="1" />
  <xsl:param name="content" />
  <xsl:text>&lt;CellStart:</xsl:text>
  <!-- rowspan -->
  <xsl:value-of select="$numRows" />
  <xsl:text>,</xsl:text>
  <!-- colspan -->
  <xsl:value-of select="$numCols" />
  <xsl:text>&gt;</xsl:text>
  <xsl:value-of select="$content" />
  <xsl:text>&lt;CellEnd:&gt;</xsl:text>
  <!-- if columns are spanned -->
  <xsl:if test="$numCols &gt; 1">
    <xsl:call-template name="addTableCells">
    <xsl:with-param name="numRows" select="1" />
    <xsl:with-param name="numCols" select="$numCols - 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

I thing similar problem was discussed here:
http://www.biglist.com/lists/xsl-list/archives/200011/msg00927.html , but
without proper solution.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.