【发布时间】:2018-05-23 20:33:59
【问题描述】:
我在使用 Apache FOP 作为处理器时遇到了 XSL-FO 问题。我有一个简单的样式表,并且已经为 fo:block-container 设置了一个圆形边框。问题是:文本大小是不可预测的,因为 .fo 文件将使用 XSLT 和 XML 生成,所以我需要告诉 FOP 根据文本宽度调整边框宽度,而不是应用相同的宽度所有的容器。有什么想法吗?
在 XSLT 文件中:
<fo:block-container xsl:use-attribute-sets="right-side-itens">
<fo:block-container xsl:use-attribute-sets="rounded-borders">
<fo:block>
<xsl:value-of-select="./tagInsideXML/@attribute" />
<!-- qwertyuiopasdfghjkl -->
</fo:block>
</fo:block-container>
<fo:block-container>
`
在styles.xsl 外部文件中:
<xsl:attribute-set name="right-side-itens">
<xsl:attribute name="top">35px</xsl:attribute>
<xsl:attribute name="right">45px</xsl:attribute>
<xsl:attribute name="text-align">end</xsl:attribute>
<xsl:attribute name="font-size">10px</xsl:attribute>
<xsl:attribute name="height">10cm</xsl:attribute>
<xsl:attribute name="width">200px</xsl:attribute>
<xsl:attribute name="position">absolute</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="rounded-borders">
<xsl:attribute name="margin-top">2px</xsl:attribute>
<xsl:attribute name="margin-right">1.8px</xsl:attribute>
<xsl:attribute name="padding-right">2px</xsl:attribute>
<xsl:attribute name="float">right</xsl:attribute>
<xsl:attribute name="line-height">18px</xsl:attribute>
<xsl:attribute name="font-size">8px</xsl:attribute>
<xsl:attribute name="border">solid 1.2px #000000</xsl:attribute>
<xsl:attribute name="fox:border-radius">6px</xsl:attribute>
<xsl:attribute name="position">relative</xsl:attribute>
<xsl:attribute name="overflow">visible</xsl:attribute>
</xsl:attribute-set>
【问题讨论】:
-
您能否提供更多详细信息,例如示例 XSL-FO 或屏幕截图以及当前问题的说明?
-
您好,我添加了一个示例代码和一个经过编辑的图像来阐明我的目标。提前致谢。
标签: xml xslt xsl-fo apache-fop