[xsl] Finding a fo:table-cells parent column's width for nested table

Subject: [xsl] Finding a fo:table-cells parent column's width for nested table
From: "JD Daniels" <jd@xxxxxxxxxxxx>
Date: Thu, 6 Mar 2003 14:15:59 -0800
I have this template to make a fo:table element from a html table. It works
fine, but it uses a pagewidth variable, which I have set at the top of the
style sheet. (It is the printable area of my fo page)
So What is happening, is if a table occurrs inside a table cell, my
figure-out-the-width temlpate only has the global variable.. which is the
width of the whole page.. not the containing cell

I have changed it so that the template that figures out the width uses a
param i pass it, but how can I figure out if the table is inside a table
cell, and pass it the value of the parent table cells parent fo:table-column
width?

I got this template culled from a few different snippets I have found on the
mailing lists and renderx's site... I do not really understand
preceding-sibling::* | following-sibling::*      stuff  :P


<xsl:template match="table|tbody">
<fo:table>
 <xsl:for-each select="tr[1]/th|tr[1]/td">
  <fo:table-column>
  <xsl:attribute name="column-width">
   <xsl:call-template name="process-col-width">
    <xsl:with-param name="width" select="@width"/>
    <xsl:with-param name="numcols">
     <xsl:value-of select="number(count(preceding-sibling::* |
following-sibling::*) + 1)"/>
    </xsl:with-param>
    <xsl:with-param name="parentblockwidth">
     <xsl:value-of select="$bodywidth"/>
    </xsl:with-param>
   </xsl:call-template>
  </xsl:attribute>
  </fo:table-column>
 </xsl:for-each>
<fo:table-body>
 <xsl:apply-templates />
</fo:table-body>
</fo:table>
</xsl:template>

Example output would be:

- <fo:table>
  <fo:table-column column-width="70mm" />
  <fo:table-column column-width="70mm" />
  <fo:table-column column-width="70mm" />
- <fo:table-body>
- <fo:table-row>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block>test</fo:block>
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
  </fo:table-row>
- <fo:table-row>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block>test</fo:block>
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
  </fo:table-row>
- <fo:table-row>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block />
  </fo:table-cell>
- <fo:table-cell border-style="solid" border-width="1pt">
  <fo:block>test</fo:block>
  </fo:table-cell>
  </fo:table-row>
  </fo:table-body>
  </fo:table>
  </fo:block>
  </fo:table-cell>
  </fo:table-row>
  </fo:table-body>
  </fo:table>



JD


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread