xsl-list
[Top] [All Lists]

Re: Splitting merged XHTML cells

2004-12-19 20:45:01
Grid meant static (global) array.
Long time ago I solved this problem. And I cheated: I used JavaScript embeded 
into XSLT (using
MSXML) so I reconstructed the table into a grid.
--- honyk <honyk(_at_)seznam(_dot_)cz> wrote:

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.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




=====
Marian
http://www.utdallas.edu/~mgo031000/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




=====
Marian
http://www.utdallas.edu/~mgo031000/


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>