xsl-list
[Top] [All Lists]

[xsl] determine maximum columns in table

2008-10-07 20:21:43
I have input XML which includes tables of the following form:
  table
   - tt?
   - th?
      - tr*
         - td*
   - tb
      - tr*
         - td*
   - tf?
      - tr*
         - td*
 
The requirement is to determine the maximum number of columns in the table.
The number of columns spanned by a cell (td) element is provided in a
colspan attribute, and if no colspan attribute exists the cell of course
occupies one column.

The following XSL template is defective inasmuch as it ignores colspan. The
context node when this template is called is <table>.

 <!-- output maximum number of columns in any child row -->
 <xsl:template name="counttablecols">
  <xsl:for-each select="*/tr">
   <xsl:sort select="count(td)" order="descending" />
   <xsl:if test="position() = 1">
    <xsl:value-of select="count(td)" />
   </xsl:if>
  </xsl:for-each>
 </xsl:template>

I can't see how to modify the sort so that I count 1 for each non-colspanned
td and the appropriate value for each td which does have a colspan
attribute. Is it possible?

An XSL 1.0 solution is preferred.

Cheers
Trevor



--~------------------------------------------------------------------
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>