Table style templates

Hi,

I'm almost new to XSL and XSL-FO and I'm wondering if there is some
possibility to define style templates for tables.

Currently I'm doing somthing like this:

....
<fo:table table-layout="fixed" width="100%" border-style="solid">

  <fo:table-column column-width="proportional-column-width(100)"/>
  <fo:table-column column-width="proportional-column-width(18)"/>
  <fo:table-column column-width="proportional-column-width(16)"/>
  <fo:table-column column-width="proportional-column-width(16)"/>
  <fo:table-column column-width="proportional-column-width(25)"/>
  
  <fo:table-header border-style="solid" background-color="lightgray">
    <fo:table-cell border-style="solid" padding="2pt">
      <fo:block font-weight="bold">Documentname</fo:block>
    </fo:table-cell>
    <fo:table-cell border-style="solid" padding="2pt">
      <fo:block font-weight="bold">Version</fo:block>
    </fo:table-cell>
    <fo:table-cell border-style="solid" padding="2pt">
      <fo:block font-weight="bold">Format</fo:block>
    </fo:table-cell>
    <fo:table-cell border-style="solid" padding="2pt">
      <fo:block font-weight="bold">Status</fo:block>
    </fo:table-cell>
    <fo:table-cell border-style="solid" padding="2pt">
      <fo:block font-weight="bold">Sector</fo:block>
    </fo:table-cell>
  </fo:table-header>
  
  <fo:table-body>
    <xsl:apply-templates />
  </fo:table-body>
</fo:table>

....
<xsl:template match="attachment">
  <fo:table-row>
    <fo:table-cell padding-before="1pt" padding-after="1pt"
padding-start="2pt" padding-end="2pt"
        border-style="solid">
      <fo:block><xsl:value-of select="name" /></fo:block>
    </fo:table-cell>
    <fo:table-cell padding-before="1pt" padding-after="1pt"
padding-start="2pt" padding-end="2pt"
        border-style="solid">
      <fo:block><xsl:value-of select="version" /></fo:block>
    </fo:table-cell>
    <fo:table-cell padding-before="1pt" padding-after="1pt"
padding-start="2pt" padding-end="2pt"
        border-style="solid">
      <fo:block><xsl:value-of select="format" /></fo:block>
    </fo:table-cell>
    <fo:table-cell padding-before="1pt" padding-after="1pt"
padding-start="2pt" padding-end="2pt"
        border-style="solid">
      <fo:block><xsl:value-of select="status" /></fo:block>
    </fo:table-cell>
    <fo:table-cell padding-before="1pt" padding-after="1pt"
padding-start="2pt" padding-end="2pt"
        border-style="solid">
      <fo:block><xsl:value-of select="sector" /></fo:block>
    </fo:table-cell>
  </fo:table-row>
</xsl:template>

My problem is that for each data cell the style has to be defined
explicitly. That is there are multiple padding and border-style tags that
are just redundant. And these format related things are furthermore part of
the section that handles the actual data, which is not that nice from my
point of view.

What I'm thinking of is to define the actual style of the whole table (i.e.
padding, borders, heading style, etc.) in some kind of reference design that
can be referred on in the stylesheet. Similar to CSS ore even the page
master definition in XSL-FO one should be able to say

<fo:table table-style-reference="MyNiceLookingTable">
  <!-- the data oriented stuff goes here -->
</fo:table>

Thus one is not bordered with the table design everytime when adding a new
row or even when adding a second table that should look the same...

Is something like this possible using XSL-FO?

Best regards,
Daniel.
-- 
View this message in context: http://www.nabble.com/Table-style-templates-tp20476932p20476932.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.

Received on Thursday, 13 November 2008 09:19:55 UTC