如何设置所有相同 XSL FO 元素的样式? XSL FO 喜欢 CSS?

How to style all the same XSL FO elements? XSL FO like CSS?

XSL FO 中有一种方法可以同时设置所有相同 XSL FO 元素的样式吗?来源在 XML.

示例:

<fo:table-row> {border-bottom: 1px solid #f0f0f0; }

代替:

<xsl:attribute-set name="border">
    <xsl:attribute name="border-bottom">1px solid #f0f0f0</xsl:attribute>
</xsl:attribute-set>

在所有地方都使用 xsl:use-attribute-sets<fo:table-row> 真是一团糟。

通常您是从 XML 和 XSL 创建 XSL FO,但这不适用,因为您会在模板匹配中为创建 table 行的内容做一些事情。所以你只会写一次。

现在,您可以使用相同的概念并创建身份 XSL,将您的 XSL FO 输入修改为新的 XSL FO,并使用 <xsl:template match="fo:table-row"> 并应用您的所有规则。