2015-09-18 71 views
1

以下功能尚未由Apache FOP實現:table-layout =「auto」(在fo:表) 我在控制檯中獲得上述警告。我正在嘗試導出到doc。使用相同的XML和XSLT,我輸出爲PDF正在運行,但輸出爲doc會給出空白文檔。Apache FOP尚未實現以下功能:table-layout =「auto」(在fo:table上)

--------------- 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>[email protected]</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>[email protected]</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>[email protected]</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>[email protected]</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>[email protected]</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>[email protected]</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> 

回答

2

嘗試添加表格的佈局=「固定」在您的FO:表,使之成爲:

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