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

determine maximum columns in table

Subject: determine maximum columns in table
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Oct 2008 13:20:58 +1300
 determine maximum columns in table
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

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.