我希望有一个var/属性来设置边框样式并引用它,这样如果我想将边框从1pt更改为2pt,就不需要在不同的位置更改它。
例如,在我做这件事的时候;
<fo:table border="1pt solid black" table-layout="fixed"
width="100%" display-align="center">
<fo:table-column column-width="10%" border-right="1pt solid black"/>
<fo:table-column column-width="10%" border-right="1pt solid black"/>
<fo:table-column column-width="23%" border-right="1pt solid black"/>
<fo:table-column column-width="8%" border-right="1pt solid black"/>
<fo:table-column column-width="11%" border-right="1pt solid black"/>
<fo:table-column column-width="8%" border-right="1pt solid black"/>
<fo:table-column column-width="20%" border-right="1pt solid black"/>
<fo:table-header>...我更喜欢这样的东西:
<xsl:variable
name="border"
select="1pt solid black">
</xsl:variable>
<fo:table border="$border" table-layout="fixed"
width="100%" display-align="center">
<fo:table-column column-width="10%" border-right="$border"/>
<fo:table-column column-width="10%" border-right="$border"/>
<fo:table-column column-width="23%" border-right="$border"/>
<fo:table-column column-width="8%" border-right="$border"/>
<fo:table-column column-width="11%" border-right="$border"/>
<fo:table-column column-width="8%" border-right="$border"/>
<fo:table-column column-width="20%" border-right="$border"/>
<fo:table-header>...所以我的问题是,这真的是可能的吗?如果是的话,正确的语法是什么?
任何帮助都是最好的,
提前感谢!
发布于 2018-01-08 22:32:17
像这样定义变量(使用撇号表示文字字符串,而不是xpath表达式)
<xsl:variable name="border" select="'1pt solid black'" />然后,使用Attribute Value Templates在属性中使用它
<fo:table-column column-width="20%" border-right="{$border}"/>或者,您可以使用Attribute Sets来实现这一点。像这样定义一个属性集
<xsl:attribute-set name="border">
<xsl:attribute name="border-right" select="'12pt solid black'" />
</xsl:attribute-set>然后使用它,如下所示
<fo:table-column column-width="20%" xsl:use-attribute-sets="border"/>使用属性集,您可以在集合中具有多个属性。
https://stackoverflow.com/questions/48152302
复制相似问题