2017-09-28 23 views
3

XSL-FOでPDFドキュメントを生成していて、複数のページにまたがることがあるテーブルがあります。そのような場合、私がしたいのは、最初のページ以外のすべてのページに "(続き)"ラベルを付けて、新しいページが始まるときにテーブルのヘッダーを繰り返すことです。 XSL-FOテーブルのヘッダーを続ける

は私のXSLコード:

<xsl:template name="Tooling"> 
    <fo:table xsl:use-attribute-sets="tableDefaultLayout"> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-column column-width="74mm" /> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-header xsl:use-attribute-sets="categoryDefaultFont"> 
      <fo:table-row height="7.7mm" border="0pt solid black" display-align="before" text-align="start"> 
       <fo:table-cell number-columns-spanned="4" font-size="12pt"> 
        <fo:block margin-top="3mm"> 
         <fo:retrieve-table-marker retrieve-class-name="continued" 
      retrieve-position-within-table="first-starting" 
      retrieve-boundary-within-table="table-fragment"/> 
      &#x00A0; 
        </fo:block> 
       </fo:table-cell> 
      </fo:table-row> 
      <fo:table-row xsl:use-attribute-sets="defaultBodyRow" height="4.7mm" border="0pt solid black"> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Item No.</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Part No.</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Description</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Qty Reqd</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
      </fo:table-row> 
     </fo:table-header> 
     <fo:table-body xsl:use-attribute-sets="valueDefaultFont" font-size="8pt"> 
      <xsl:for-each select="1 to 50"> 
       <fo:table-row xsl:use-attribute-sets="defaultBodyRow" border="0pt solid black"> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:choose> 
           <xsl:when test="position()=1"> 
            <fo:marker marker-class-name="continued"> 
             <xsl:text>TOOLING:-</xsl:text> 
            </fo:marker> 
           </xsl:when> 
           <xsl:otherwise> 
            <fo:marker marker-class-name="continued"> 
             <xsl:text>TOOLING: (continued)</xsl:text> 
            </fo:marker> 
           </xsl:otherwise> 
          </xsl:choose> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]ESC</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
       </fo:table-row> 
      </xsl:for-each> 
     </fo:table-body> 
    </fo:table> 
</xsl:template> 

そしてFOが生成:

<fo:table border-bottom="0.5pt solid black" border-collapse="collapse" border-left="1pt solid black" border-right="1pt solid black" border-top="0.5pt solid black" margin="0mm" padding="0mm" table-layout="fixed" width="100%"> 
       <fo:table-column column-width="37mm"/> 
       <fo:table-column column-width="37mm"/> 
       <fo:table-column column-width="74mm"/> 
       <fo:table-column column-width="37mm"/> 
       <fo:table-header font-family="sans-serif" font-size="10pt" font-weight="bold"> 
        <fo:table-row border="0pt solid black" display-align="before" height="7.7mm" text-align="start"> 
         <fo:table-cell font-size="12pt" number-columns-spanned="4"> 
          <fo:block margin-top="3mm"> 
           <fo:retrieve-table-marker retrieve-boundary-within-table="table-fragment" retrieve-class-name="continued" retrieve-position-within-table="first-starting"/> 
        
          </fo:block> 
         </fo:table-cell> 
        </fo:table-row> 
        <fo:table-row border="0pt solid black" display-align="center" height="4.7mm" keep-together.within-page="always" text-align="center"> 
         <fo:table-cell> 
          <fo:block>Item No.</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>Part No.</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>Description</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>Qty Reqd</fo:block> 
         </fo:table-cell> 
        </fo:table-row> 
       </fo:table-header> 
       <fo:table-body font-family="monospace" font-size="8pt" font-weight="normal"> 
        <fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center"> 
         <fo:table-cell> 
          <fo:block> 
           <fo:marker marker-class-name="continued">TOOLING:-</fo:marker>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
        </fo:table-row> 
        <fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center"> 
         <fo:table-cell> 
          <fo:block> 
           <fo:marker marker-class-name="continued">TOOLING: (continued)</fo:marker>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
         <fo:table-cell> 
          <fo:block>[email protected]</fo:block> 
         </fo:table-cell> 
        </fo:table-row> 

はその後50行継続:あなたが最初のものはマーカーを持っている "TOOLING: - " 見ることができるようにし、すべての他には「ツール:(続き)」というマーカーがあります。これは私が望むものです。

私の問題は、fo:retrieve-table-markerオブジェクトを正しく動作させることができないということです。「retrieve-position」属性と「retrieve-boundary」属性で複数の組み合わせを試みましたが、私のヘッダーの最初の行は、最初または他のページで常に空白です。

「fo:retrieve-table-marker」オブジェクトと「fo:marker」オブジェクトで間違っていることを誰かが私に説明することができれば、本当の助けになるでしょう。私はこの問題に苦労しています今の数日間。

+0

私はしばらく前に同様の問題があった(前にマーカーを取得しよう最初のfo:markerの出現)、最初の検索マーカーの前に余分なfo:markerのインスタンスを置くことで回避しました。しかし、それはうまくいくはずはありません。 – Hobbes

+0

'table-omit-header-at-break =" true "'を設定しました。マーカーは表ヘッダーでのみ使用できるので、表ヘッダーの表示を要求しない場合は、** Continued **は表示されません。それ以外のコードは正しいです。 – potame

+0

申し訳ありませんが、 "table-omit-header-at-break"はコピー/ペーストエラーです。この属性を追加して、実際に何が起こったのかを確認しようとしましたが、 @Hobbesはヒントありがとう、私はこれを試してみる – eipiplusun

答えて

0

table-omit-header-at-break="true"が設定されています。マーカーはテーブルヘッダーでのみ使用できるので、テーブルヘッダーを表示するように要求しないと、続行は表示されません。それ以外のコードは正しいです。

次のようにこのように私はあなたのXSLTコードを修正します:

まず、<xsl:attribute-set name="tableDefaultLayout">定義の中に、スタイルシート内の他の場所で見つけることができる<xsl:attribute name="table-omit-header-at-break">true</xsl:attribute>を削除します。その後

そうのようなあなたのテンプレートを変更する:すべての行でfo:markerを生成することの代替として

<xsl:template name="Tooling"> 
    <fo:table xsl:use-attribute-sets="tableDefaultLayout"> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-column column-width="74mm" /> 
     <fo:table-column column-width="37mm" /> 
     <fo:table-header xsl:use-attribute-sets="categoryDefaultFont"> 
      <fo:table-row height="7.7mm" border="0pt solid black" display-align="before" text-align="start"> 
       <fo:table-cell number-columns-spanned="4" font-size="12pt"> 
        <fo:block margin-top="3mm"> 
         <fo:retrieve-table-marker retrieve-class-name="continued" 
      retrieve-position-within-table="first-starting" 
      retrieve-boundary-within-table="table-fragment"/> 
      &#x00A0; 
        </fo:block> 
       </fo:table-cell> 
      </fo:table-row> 
     </fo:table-header> 
     <fo:table-body xsl:use-attribute-sets="valueDefaultFont" font-size="8pt"> 
      <fo:table-row xsl:use-attribute-sets="defaultBodyRow" height="4.7mm" border="0pt solid black"> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Item No.</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Part No.</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Description</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
       <fo:table-cell> 
        <fo:block> 
         <xsl:text>Qty Reqd</xsl:text> 
        </fo:block> 
       </fo:table-cell> 
      </fo:table-row> 
      <xsl:for-each select="1 to 50"> 
       <fo:table-row xsl:use-attribute-sets="defaultBodyRow" border="0pt solid black"> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:choose> 
           <xsl:when test="position()=1"> 
            <fo:marker marker-class-name="continued"> 
             <xsl:text>TOOLING:-</xsl:text> 
            </fo:marker> 
           </xsl:when> 
           <xsl:otherwise> 
            <fo:marker marker-class-name="continued"> 
             <xsl:text>TOOLING: (continued)</xsl:text> 
            </fo:marker> 
           </xsl:otherwise> 
          </xsl:choose> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
        <fo:table-cell> 
         <fo:block> 
          <xsl:text>[email protected]</xsl:text> 
         </fo:block> 
        </fo:table-cell> 
       </fo:table-row> 
      </xsl:for-each> 
     </fo:table-body> 
    </fo:table> 
</xsl:template> 
+0

"table-omit-header-at-break"属性はコピー/ペーストエラーだったので、私はそれを削除しましたが、問題は変わりません:私の頭の2行目(「商品番号」、「部品番号」など)がすべてのページに表示されます(これは私が望むものなので、 )ですが、 "TOOLING:[(continued)]"でなければならない最初の行は実際には空白です。 – eipiplusun

0

<fo:table-header xsl:use-attribute-sets="categoryDefaultFont"> 
    <fo:table-row height="7.7mm" border="0pt solid black" 
        display-align="before" text-align="start"> 
     <fo:table-cell number-columns-spanned="4" font-size="12pt"> 
      <fo:block margin-top="3mm">TOOLING:-<fo:retrieve-table-marker 
        retrieve-class-name="continued" 
        retrieve-position-within-table="last-starting"/> 
      </fo:block> 
     </fo:table-cell> 
    </fo:table-row> 
    ... 
</fo:table-header> 
<fo:table-body xsl:use-attribute-sets="valueDefaultFont" font-size="8pt"> 
    <fo:marker marker-class-name="continued" /> 
    <fo:marker marker-class-name="continued"> (continued)</fo:marker> 
    <xsl:for-each select="1 to 50"> 
     <fo:table-row xsl:use-attribute-sets="defaultBodyRow" 
         border="0pt solid black"> 
    ... 
+0

私はそれが私のコードをどのように明るくするのか見ていますが、私の問題は解決しません。 :/ – eipiplusun

+0

これはAH Formatter V6.5で動作します。どのフォーマッターを使用していますか? –

+0

長いこと返答して申し訳ありませんが、私はそのことについて同僚に尋ねなければなりませんでした。それで、FPCと呼ばれる特定のフォーマッタを使用して、fo:markerというマークアップを認識しても無視します。最終的に 'fo:table'マークアップに追加する' fpc:table-omit-header-at-start = "true" '属性を見出しました。これによりヘッダは最初のページを除くすべてのページに表示され、最初のページの特定のヘッダーを本文の最初の行として追加します。 とにかく、問題は解決しました。あなたの時間をすみませんでした。申し訳ありません。 – eipiplusun

関連する問題