Question

I use one style for the borders for the tables in my xsl-fo template. Is there a way to define the following as a style-variable and use the "variable" where I want to apply this style?

For example:

 padding-top="0pt" 
 padding-left="3.5pt" 
 padding-bottom="0pt" 
 padding-right="3.5pt" 
 border-top-style="solid" 
 border-top-color="black" 
 border-top-width="0.5pt" 
 border-left-style="solid" 
 border-left-color="black" 
 border-left-width="0.5pt" 
 border-bottom-style="solid" 
 border-bottom-color="black" 
 border-bottom-width="0.5pt" 
 border-right-style="solid" 
 border-right-color="black" 
 border-right-width="0.5pt" 
 display-align="center"

I hope that I can use something like

 <fo:table-row ${border-style-1}>
 .....
    <fo:table-cell ${border-style-2}

with ${var} I hope that var will be substituted with the whole style text.

Was it helpful?

Solution

You would define and then use attribute-sets, you can use them anywhere.

You use something like this:

<xsl:attribute-set name="row-style">
  <xsl:attribute name="padding-top">0pt</xsl:attribute>
  <xsl:attribute name="padding-left">3.5pt</xsl:attribute>
  <!-- rest of your attributes you wish here -->
</xsl:attribute-set>

and then on the actual object:

 <fo:table-row xsl:use-attribute-sets="row-style">

Also note that if you have repeatable chunks you wish to reuse, one definition of an attribute-set can use another in the same way, like:

 <xsl:attribute-set name="row-style" xsl:use-attribute-sets="inherit-me">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top