XSL-FO table 需要圆角吗?
Need rounded corner for XSL-FO table?
我正在借助 XSL-FO 模板语言将 XML 数据转换为 PDF 文件,想要 header table 和数据 table布局如下图样
现在我只有尖角用过 fox:border-radius
属性 但没用。
我的XSL-FO:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:template match="root">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello, <xsl:value-of select="name" />!</fo:block>
<fo:block>
<fo:table width="100%" fox:border-radius="4em" border=".125em solid #000000">
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
No.
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
Name
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
Phone Number
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table width="100%" fox:border-radius="4em" border=".125em solid #000000">
<fo:table-body>
<xsl:for-each select="./friend">
<xsl:for-each select="./closefriends">
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="position()" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="../name" />
<xsl:value-of select="names" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="phNo" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
我不知道,我在这里缺少什么来实现 table 的圆角边框。
为了在带有 FOP 的桌子上产生圆角,您必须解决两件事:
- 添加
fox
命名空间前缀的声明,绑定到 http://xmlgraphics.apache.org/fop/extensions
(参见 http://xmlgraphics.apache.org/fop/trunk/extensions.html#fox-namespace)。
- 将
border-collapse
属性 的值设置为 "separate"(参见 http://xmlgraphics.apache.org/fop/trunk/extensions.html#rounded-corners)。
我正在借助 XSL-FO 模板语言将 XML 数据转换为 PDF 文件,想要 header table 和数据 table布局如下图样
现在我只有尖角用过 fox:border-radius
属性 但没用。
我的XSL-FO:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:template match="root">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello, <xsl:value-of select="name" />!</fo:block>
<fo:block>
<fo:table width="100%" fox:border-radius="4em" border=".125em solid #000000">
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
No.
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
Name
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black"
text-align="center" font-weight="bold">
<fo:block>
Phone Number
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table width="100%" fox:border-radius="4em" border=".125em solid #000000">
<fo:table-body>
<xsl:for-each select="./friend">
<xsl:for-each select="./closefriends">
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="position()" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="../name" />
<xsl:value-of select="names" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="phNo" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
我不知道,我在这里缺少什么来实现 table 的圆角边框。
为了在带有 FOP 的桌子上产生圆角,您必须解决两件事:
- 添加
fox
命名空间前缀的声明,绑定到http://xmlgraphics.apache.org/fop/extensions
(参见 http://xmlgraphics.apache.org/fop/trunk/extensions.html#fox-namespace)。 - 将
border-collapse
属性 的值设置为 "separate"(参见 http://xmlgraphics.apache.org/fop/trunk/extensions.html#rounded-corners)。