2014-03-06 19 views
2

我在xsl-fo模板中为表格的边框使用了一种样式。有没有办法将下面的代码定义为一个样式变量,并在我想应用这种样式的地方使用“变量”?在xsl-fo文档中只定义一次边框

例如:

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" 

我希望我可以使用类似

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

${var}我希望var将与整体风格的文字来代替。

回答

2

您将定义并使用属性集,您可以在任何地方使用它们。

您可以使用这样的事情:

<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> 

,然后实际的对象:

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

还要注意的是,如果你有重复的块,你想重用,一个属性 - 的一个定义设置可以用相同的方式使用另一个,如:

<xsl:attribute-set name="row-style" xsl:use-attribute-sets="inherit-me"> 
+0

代码对于给出的示例如何? –

+0

已更新样本,应该会对您有所帮助。 –