[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] xslfo table paging


Subject: Re: [xsl] xslfo table paging
From: Max <max@xxxxxxxxxxx>
Date: Wed, 16 Jul 2008 14:40:00 +0100

philip.vallone@xxxxxxxxxxx wrote:
Hi Max,
The FOP forum on nabble might be a better place as I think your question is related to XSL-Fo. see http://www.nabble.com/FOP---Users-f353.html.


Nevertheless, can you post some of the relevant FO/xsl?

Phil
The table XSLT code is below. It just mimics html table code.

Regards Max

<xsl:template match="tbody">
<fo:table table-layout="fixed" width="100%">
  <xsl:for-each select="tr[1]/th|tr[1]/td">
      <fo:table-column column-width="proportional-column-width(1)" >
      </fo:table-column>
  </xsl:for-each>

<fo:table-body>
  <xsl:apply-templates />
</fo:table-body>

</fo:table>
</xsl:template>

<!-- this one's easy; <tr> corresponds to <fo:table-row> -->
<xsl:template match="tr">
<fo:table-row> <xsl:apply-templates/> </fo:table-row>
</xsl:template>

<!--
  Handle table header cells. They should be bold
  and centered by default. Look back at the containing
  <table> tag to see if a border width was specified.
-->
<xsl:template match="th">
<fo:table-cell font-weight="bold" text-align="center">
  <xsl:if test="ancestor::table[1]/@border > 0">
      <xsl:attribute name="border-style">solid</xsl:attribute>
      <xsl:attribute name="border-width">1pt</xsl:attribute>
  </xsl:if>
  <fo:block>
  <xsl:apply-templates/>
  </fo:block>
</fo:table-cell>
</xsl:template>

<!--
  Handle table data cells.  Look back at the containing
  <table> tag to see if a border width was specified.
-->
<xsl:template match="td">
<fo:table-cell>
  <xsl:if test="ancestor::table/@border > 0">
      <xsl:attribute name="border-style">solid</xsl:attribute>
      <xsl:attribute name="border-width">1pt</xsl:attribute>
  </xsl:if>
  <fo:block>
  <!-- set alignment to match that of <td> tag -->
  <xsl:choose>
  <xsl:when test="@align='left'">
      <xsl:attribute name="text-align">start</xsl:attribute>
  </xsl:when>
  <xsl:when test="@align='center'">
      <xsl:attribute name="text-align">center</xsl:attribute>
  </xsl:when>
  <xsl:when test="@align='right'">
      <xsl:attribute name="text-align">end</xsl:attribute>
  </xsl:when>
  </xsl:choose>
  <xsl:apply-templates/>
  </fo:block>
</fo:table-cell>
</xsl:template>


Current Thread
Keywords