2017-08-13 65 views
0

我有以下XML作为输入无法显示在该地区开始所有线路中的PDF文件

<AFPXMLFile> 
    <docs> 
    <regList> 
    </regList> 
    <regList> 
     <region>2</region> 
     <secList> 
      <col>2</col> 
      <lines> 
      <line>IBM BELGIUM SPRL/BVBA </line> 
      <line>d'entreprise/Ondernemingsnr TVA/BTW</line> 
      <line>405 912 336/03.28.1.3 DISPENSE </line> 
      </lines> 
     </secList> 
     </regList> 
     <regList></regList> 
     <regList></regList> 
    </docs> 

我对开始区域XSL如下:

<xsl:when test="region = '2'"> 
      <fo:static-content flow-name="xsl-region-start"> 
       <xsl:for-each select="./secList/lines"> 
        <xsl:for-each select="node()"> 
        <fo:block-container reference-orientation="90" white-space="pre" font-size="4pt" color="green"> 
        <fo:block> 
          <xsl:value-of select="."/> 
          <fo:leader /> 
        </fo:block>   
        </fo:block-container> 
        </xsl:for-each> 
       </xsl:for-each> 
      </fo:static-content>  
     </xsl:when> 

我我的PDF文件我只看到第一行IBM BELGIUXxxx。我没有看到第二和第三行。如果我删除方向,我会看到所有三行。

我缺少什么?

回答

0

如果您希望自上而下堆栈fo:block-container,则应该明确指定每个fo:block-container@inline-progression-dimension。这里是示例XSL-FO。

<?xml version="1.0" encoding="UTF-8"?> 
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
    <fo:layout-master-set> 
     <fo:simple-page-master master-name="spm" page-width="10.5in" page-height="10.5in"> 
      <fo:region-body margin-top="1in" margin-bottom="1in" margin-left="1in" 
       margin-right="1in" overflow="error-if-overflow"/> 
      <fo:region-before extent="1in" precedence="true" display-align="after"/> 
      <fo:region-start extent="1in"/> 
      <fo:region-end extent="1in"/> 
     </fo:simple-page-master> 
    </fo:layout-master-set> 
    <fo:page-sequence master-reference="spm" reference-orientation="from-page-master-region()" 
     writing-mode="from-page-master-region()"> 
     <fo:static-content flow-name="xsl-region-before"> 
      <fo:block border-bottom="1.5pt solid blue"/> 
     </fo:static-content> 
     <fo:static-content flow-name="xsl-region-start"> 
      <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em"> 
       <fo:block white-space="pre" font-size="9pt" color="green">IBM BELGIUM SPRL/BVBA</fo:block> 
      </fo:block-container> 
      <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em"> 
       <fo:block white-space="pre" font-size="9pt" color="green">d'entreprise/Ondernemingsnr TVA/BTW</fo:block> 
      </fo:block-container> 
      <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em"> 
       <fo:block white-space="pre" font-size="9pt" color="green">405 912 336/03.28.1.3 DISPENSE</fo:block> 
      </fo:block-container> 
     </fo:static-content> 
     <fo:flow flow-name="xsl-region-body"> 
      <fo:block font-size="1.2em" space-before="2mm" space-before.conditionality="retain">Region-start test</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
     </fo:flow> 
    </fo:page-sequence> 
</fo:root> 

[通过FOP格式化结果]

Formatting result via FOP

或者,如果你想从左边<line>元素设置为正确的,产生fo:block-container<lines>元素。 [通过FOP格式化结果]

[样品FO文件]

<?xml version="1.0" encoding="UTF-8"?> 
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
    <fo:layout-master-set> 
     <fo:simple-page-master master-name="spm" page-width="10.5in" page-height="10.5in"> 
      <fo:region-body margin-top="1in" margin-bottom="1in" margin-left="1in" 
       margin-right="1in" overflow="error-if-overflow"/> 
      <fo:region-before extent="1in" precedence="true" display-align="after"/> 
      <fo:region-start extent="1in"/> 
      <fo:region-end extent="1in"/> 
     </fo:simple-page-master> 
    </fo:layout-master-set> 
    <fo:page-sequence master-reference="spm" reference-orientation="from-page-master-region()" 
     writing-mode="from-page-master-region()"> 
     <fo:static-content flow-name="xsl-region-before"> 
      <fo:block border-bottom="1.5pt solid blue"/> 
     </fo:static-content> 
     <fo:static-content flow-name="xsl-region-start"> 
      <fo:block-container reference-orientation="90" text-align="right"> 
       <fo:block white-space="pre" font-size="9pt" color="green">IBM BELGIUM SPRL/BVBA</fo:block> 
       <fo:block white-space="pre" font-size="9pt" color="green">d'entreprise/Ondernemingsnr TVA/BTW</fo:block> 
       <fo:block white-space="pre" font-size="9pt" color="green">405 912 336/03.28.1.3 DISPENSE</fo:block> 
      </fo:block-container> 
     </fo:static-content> 
     <fo:flow flow-name="xsl-region-body"> 
      <fo:block font-size="1.2em" space-before="2mm" space-before.conditionality="retain">Region-start test</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
      <fo:block>Body text.</fo:block> 
     </fo:flow> 
    </fo:page-sequence> 
</fo:root> 

enter image description here

希望这有助于你的样式表的发展。

+0

感谢您回复我的问题。对不起,我忘了提及行数是动态的,在一段中可以是3行,而在另一段中可以是2等。 – Madhu

+0

@Madhu如果每行的行数(或内容)数量不同,您应该生成fo:按章节单位的页面顺序。这可以分别生成fo:region的静态内容。 – tmakita

+0

感谢您的建议。这个内嵌的进程尺寸=“15em”属性有所帮助。我在PDF文件中显示了所有3行。虽然它没有在它们之间添加换行符。我会努力的。 – Madhu