xsl-list
[Top] [All Lists]

Re: problem with table

2004-09-20 03:44:11
At 2004-09-20 15:21 +0530, Eldho George wrote:
I have some problem with <fo:table-column>.Suppose i am using different
table structure such as
first <tr> contains 3 <td>.Second <tr> contains 4 <td>.Then 3<tr> onwards it
contains 6 <td>
The following is my table template.
<xsl:for-each select="tr/th|tr/td|thead/tr/th|thead/tr/td">
        <fo:table-column/>
</xsl:for-each>

This would obtain *every* th and *every* td and give you one table column per item, which is why you are getting so many columns.

Remember that all rows in an XSL-FO table will render with the same number of columns and the column edges will be the same for all rows in a single table.

Thus, you need only traverse the maximum number of columns. The maximum number of columns can be obtained by sorting the rows by the number of columns, sorting them in descending order, and acting on the first of those:

      <xsl:for-each select="tr|thead/tr">
        <xsl:sort select="count(td|th)" data-type="number"
                  order="descending"/>
        <xsl:if test="position()=1">
          <xsl:for-each select="td|th">
            <table-column/>
          </xsl:for-each>
        </xsl:if>
      </xsl:for-each>

I hope this helps.

............................ Ken




--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



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