2017-04-14 40 views
0

我想嘗試一個小列表的兩列布局。我複製了現有的簡單頁面主,並添加了column-count="2"。 (爲簡潔起見,我不包括頁眉或頁腳)。如果刪除fo:page-sequencefo:flow,模板將按預期工作,但否則我在輸出中沒有任何內容。我嘗試用numIndex替換另一個模板,但也失敗了。fo:page-sequence兩列沒有出現在輸出XSL-FO

我正在使用天線之家。一如往常,我很欣賞任何建議。

<fo:simple-page-master master-name="body-page-two-col" xsl:use-attribute-sets="odd-page-atts"> 
    <fo:region-body region-name="region-body" xsl:use-attribute-sets="body-atts" column-count="2"/> 
</fo:simple-page-master> 

<xsl:attribute-set name="odd-page-atts"> 
     <xsl:attribute name="page-height">11in</xsl:attribute> 
     <xsl:attribute name="page-width">8.5in</xsl:attribute> 
     <xsl:attribute name="margin-top">1.5pc</xsl:attribute> 
     <xsl:attribute name="margin-bottom">1.5pc</xsl:attribute> 
     <xsl:attribute name="margin-left">1in</xsl:attribute> 
     <xsl:attribute name="margin-right">.5in</xsl:attribute> 
    </xsl:attribute-set> 

<xsl:attribute-set name="body-atts"> 
     <xsl:attribute name="margin-top">4.5pc</xsl:attribute> 
     <xsl:attribute name="margin-bottom">4.5pc</xsl:attribute> 
    </xsl:attribute-set> 

    <xsl:template name="numIndex"> 
     <fo:page-sequence master-reference="body-page-two-col" initial-page-number="auto" format="1"> 
      <fo:flow flow-name="region-body"> 
<fo:block> 
      <fo:table-and-caption> 
       <fo:table-caption> 
        <fo:block> 
         <xsl:text>Numerical Index</xsl:text> 
        </fo:block> 
       </fo:table-caption> 
       <fo:table> 
       <xsl:attribute name="id"><xsl:apply-templates select="ancestor::dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:text>tbl-numidx001</xsl:text></xsl:attribute> 
        <fo:table-header> 
         <fo:table-row> 
           <fo:table-cell> 
            <fo:block font-size="11pt" font-style="italic" >        
            <fo:retrieve-table-marker retrieve-class-name="continued-ni" retrieve-boundary-within-table="table"/> 
           </fo:block> 
          </fo:table-cell> 
         </fo:table-row> 
        </fo:table-header> 
        <fo:table-body> 
         <fo:table-row> 
          <fo:table-cell> 
           <fo:marker marker-class-name="continued-ni"/> 
           <fo:marker marker-class-name="continued-ni"> 
            <fo:block text-align="center">Numerical Index&#160; (Continued) 
            </fo:block> 
           </fo:marker> 
          </fo:table-cell> 
         </fo:table-row> 
         <fo:table-row> 
          <fo:table-cell> 
           <fo:table border-bottom="solid" border-bottom-width=".5pt" 
       border-top="solid" border-top-width=".5pt" font-size="8pt" 
       margin-bottom="8pt" margin-left="3pt" margin-right="3pt" margin-top="8pt" 
       relative-position="static" space-after.maximum="12pt" space-after.minimum="12pt" 
       space-after.optimum="12pt" space-before.maximum="14pt" space-before.minimum="12pt" 
       space-before.optimum="12pt" span="all" table-layout="fixed" table-omit-header-at-break="false" 
       table-omit-footer-at-break="true" text-align="start" white-space-treatment="preserve" 
       width="3.0in" hyphenate="true" cols="4"> 
        <fo:table-column column-number="1" column-width="30%"/> 
        <fo:table-column column-number="2" column-width="20%"/> 
        <fo:table-column column-number="3" column-width="20%"/> 
        <fo:table-column column-number="4" column-width="20%"/> 
        <fo:table-header> 
         <xsl:call-template name="NI-HEADER"/> 
        </fo:table-header> 
       <fo:table-body>  
        <xsl:call-template name="SortParts"/> 
       </fo:table-body> 
      </fo:table> 
      </fo:table-cell> 
      </fo:table-row> 
       </fo:table-body> 
       </fo:table> 
       </fo:table-and-caption> 
       </fo:flow> 
</fo:block> 
       </fo:page-sequence> 
     </xsl:template> 

這是什麼叫numIndex:

<xsl:template match="illustratedPartsCatalog"> 
      <xsl:apply-templates /> 
      <xsl:call-template name="numIndex"/> 
    </xsl:template> 

回答

1

如果我正確理解你,你需要一個表格,在你的常規一列流程中流入兩列。由於您使用的是AH格式器,因此您可以使用兩列fo:block-container來包含表格。請參閱https://www.antennahouse.com/product/ahf64/ahf-ext.html#axf.column-count。然而,這不會讓你成爲你的'(續)'標記。要做到這一點,您可以將fo:block-container作爲外部fo:tablefo:table-cell的孩子。

但是,由於我不確定我是否瞭解您的要求,您是否可以對您要查找的內容做一個簡單的圖示?另外,如果如您在代碼示例中所示,fo:simple-page-master不在xsl:template之內,那麼它將被XSLT處理器忽略,並且不會出現在您的FO文件中。

根據https://www.w3.org/TR/xslt#stylesheet-element

XSLT處理器總是自由地忽略這樣的頂層元素,且必須忽略一個頂級元素而不給一個錯誤,如果它不能識別的命名空間URI。

+0

事實上,託尼,這是我想要的,索引表現在兩列。我需要跨越標題和持續的標記,但我想我可以弄明白。我正要嘗試實現這個[http://stackoverflow.com/questions/2461866/xsl-list-divided-into-columns](http://stackoverflow.com/questions/2461866/xsl-list-divided-入列),但雙列容器正在爲我工​​作。謝謝! – Caroline

+0

關於'fo:simple-page-master'的語法不正確? 'fo:simple-page-master'與其他頁面集合(從主.xsl文件中調用)是分開的文件,我不打算使用'fo:page-sequence-master'和頁眉和頁腳,直到我有兩列的格式工作。 – Caroline

+0

問題不在於語法,而在於標記的位置。由於'fo:simple-page-master'似乎不在任何'xsl:template'之外,因此它不會在結果文檔中結束。對於任何'xsl:stylesheet'子元素的非XSLT元素也是如此,所以它與XSL-FO標記的正確性無關。 –

0

我可以看到2個問題:

  1. 您爲FO指定width="7.0in":表中,因此它不適合在比這更窄的列內。你的列只有3.5「,減去列間的列間距(12pt,如果你沒有另外指定的話)。表格將流到足夠寬的第一個正文頁面以容納它們。

  2. template match="illustratedPartsCatalog"首先做一個應用模板。如果產生一個頁面序列,並不會關閉它,在call-template name="numIndex"將嘗試創建一個嵌套頁面序列,這將無法正常工作。

的FO模板與</fo:layout-master-set>開始

然後有兩種方法可以進行:可以使用template match="node"來匹配XML中根節點的每個子節點,或者您可以使用xsl:call-template命令。這爲您提供了更大的靈活性,您可以構建一個模板,以生成一個包含多個根節點子項的頁面序列。

所以,你可以這樣做:

<xsl:call-template name="insertIllustratedPartsCatalog"/> 
<xsl:call-template name="numIndex"/> 

其中insertIllustratedPartsCatalog創建零件目錄頁面序列,並numIndex創建索引頁面序列。

(如果沒有看到整個FO模板,很難獲得更具體的結果)。

+0

謝謝,我將寬度更改爲3英寸,但沒有任何顯示。 – Caroline

+0

發現了另一個問題,並修改了我的答案... – Hobbes

+0

再次感謝,我添加了塊和相同的結果。我怎麼知道頁面序列是否已經從'illustratedPartsCatalog'關閉了? – Caroline