【问题标题】:The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table)Apache FOP 尚未实现以下功能:table-layout="auto" (on fo:table)
【发布时间】:2015-09-18 07:25:10
【问题描述】:

Apache FOP 尚未实现以下功能:table-layout="auto"(在 fo:table 上)

我在控制台中得到了警告。我正在尝试导出到文档。使用相同的 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>

【问题讨论】:

    标签: xml xslt


    【解决方案1】:

    尝试在你的 fo:table 中添加 table-layout="fixed",使其变为:

    <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>
    

    【讨论】:

      猜你喜欢
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 2016-02-22
      • 2017-01-04
      • 2021-12-12
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多