Apache FOP尚未实现以下功能:table-layout =“auto”(在fo:table上)
我在控制台中发出警告。我正在尝试导出到doc。使用相同的XML和XSLT,我导出到PDF正在工作,但导出到doc会给出空白文档。
--------------- My XML -----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<export>
<signPost>
<organisationName>Organisation NEW TEST1</organisationName>
<address1>Address Line 1</address1>
<address2>Address Line 2</address2>
<address3>Address Line 3</address3>
<postCode>N194eh</postCode>
<phNumber>07999999999</phNumber>
<email>newmeh@meh.com</email>
<url>www.NOTnewmeh.com</url>
<profile>tee</profile>
</signPost>
<signPost>
<organisationName>Test Meta Organization</organisationName>
<address1 />
<address2 />
<address3 />
<postCode>N194EH</postCode>
<phNumber />
<email />
<url />
<profile />
</signPost>
<signPost>
<organisationName>Test Org Meta</organisationName>
<address1>Address Line 1</address1>
<address2>Address Line 2</address2>
<address3>Address Line 3</address3>
<postCode>N194EH</postCode>
<phNumber>07999999999</phNumber>
<email>newmeh@meh.com</email>
<url>www.NOTnewmeh.com</url>
<profile>Profile</profile>
</signPost>
<signPost>
<organisationName>eeeeeewe</organisationName>
<address1>Address Line 1</address1>
<address2>tee</address2>
<address3>Address Line 3</address3>
<postCode>n124jj</postCode>
<phNumber>07777777777</phNumber>
<email>meh@meh.com</email>
<url>meh.com</url>
<profile>Profile</profile>
</signPost>
<signPost>
<organisationName>sdfsdfs</organisationName>
<address1>Address Line 1</address1>
<address2>Address Line 2</address2>
<address3>Address Line 3</address3>
<postCode>a332kk</postCode>
<phNumber>07999999999</phNumber>
<email>newmeh@meh.com</email>
<url>www.NOTnewmeh.com</url>
<profile>Profile</profile>
</signPost>
<signPost>
<organisationName>this</organisationName>
<address1>Address Line 1</address1>
<address2>Address Line 2</address2>
<address3>Address Line 3</address3>
<postCode>n377mm</postCode>
<phNumber>07999999999</phNumber>
<email>newmeh@meh.com</email>
<url>www.NOTnewmeh.com</url>
<profile>Profile</profile>
</signPost>
<signPost>
<organisationName>New Org</organisationName>
<address1>Address Line 1</address1>
<address2>Address Line 2</address2>
<address3>Address Line 3</address3>
<postCode>NW1 2SD</postCode>
<phNumber>07999999999</phNumber>
<email>newmeh@meh.com</email>
<url>www.NOTnewmeh.com</url>
<profile>Profile</profile>
</signPost>
</export>
---------------------------
----- MY XSLT -----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="form"
page-height="29.7cm" page-width="21.0cm" margin-right="2cm"
margin-left="1cm" margin-top="1cm" margin-bottom="0cm">
<fo:region-body margin-top="1cm" margin-bottom="1cm" />
<fo:region-before region-name="header" extent="1cm" />
<fo:region-after region-name="footer" extent="1cm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="form">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="export" />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="export">
<fo:table >
<fo:table-body>
<xsl:for-each select="signPost">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<fo:table-row>
<fo:table-cell>
<fo:block padding-top="2mm">
<xsl:value-of select="organisationName" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:template>
</xsl:stylesheet>
答案 0 :(得分:3)
尝试添加table-layout =&#34; fixed&#34;在你的fo:table中,它变成了:
<fo:table table-layout="fixed">
您可能还需要添加表格的宽度
<fo:table table-layout="fixed" width="100%">
如果仍然收到警告,请尝试定义列的宽度:
...
<fo:table-column column-width="30%"/>
<fo:table-body>
...
但是,由于此警告,我怀疑您是否收到了空白文档。如果您执行以下操作,您会得到什么?
<xsl:template match="export">
<fo:block>test</fo:block>
</xsl:template>