2016-12-19 18 views
0

私はxsl-fo(Saxon XSL 2.0、AHF V6.2)を使ったpdfプリント刊行物を開発しています。Antennahouse Formatterは参照脚注をどのように扱うことができますか?

私の目標は、参照された静的テキスト要素のテキストが挿入された自動番号付き脚注(1ページに重複を除く)を持つことです。

基本的にインライン脚注(fn)は、静的な脚注のテキスト要素を参照し、インライン番号を作成し、脚注テキストをページの下部に印刷します。

<?xml version="1.0" encoding="UTF-8"?> 
<document> 
<chapter> 
    <paragraph>some description...</paragraph> 
    <paragraph>some description with a footnote <fn id="fn2"/></paragraph> 
    <paragraph>some description with a footnote <fn id="fn2"/></paragraph> 
    <paragraph>some description...</paragraph> 
    <paragraph>some description with a footnote <fn id="fn1"/></paragraph> 
</chapter> 
<!-- this is a wrapper element that will not be displayed in the rendered pdf but only contains the needed information for different footnote texts --> 
<chapter class="footnoteWrapper"> 
    <footnote id="fn1"> 
     This is the text body of footnote #1. 
    </footnote> 
    <footnote id="fn2"> 
     This is the text body of footnote #2. 
    </footnote> 
    <footnote id="fn3"> 
     This is the text body of footnote #3. 
    </footnote> 
</chapter> 
</document> 

章内の重複するインライン脚注は、それらが指している脚注に従って同じ番号を表示する必要があります。脚注要素:

これは、どのような結果が

Possible output

...のようになりますが、それはAHFの脚注の拡張とFOでこれらの目標を達成することは可能ですか?

アンテナハウスのフォーマッタエクステンションは、fnカウントに使用すると奇妙な動作をします。彼らは参照されている脚注の正しい現在の番号を参照するのではなく、(1、2、3)を数え続けます。

これは、これまでXSL(単に関連抜粋)である:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 

<xsl:template match="fn[@id = //footnote/@nodeid]" 
    mode="content" 
    priority="7"> 
    <!--+ fn link 
     | 
     | basic fn (inline) link template. 
     | 
     +--> 
    <xsl:apply-templates select="//footnote[@id = current()/@id]" 
     mode="content"/> 
</xsl:template> 

<xsl:template match="footnote" 
    mode="content" 
    priority="5"> 
    <!--+ footnote 
     | 
     | basic footnote template. 
     | 
     +--> 
    <fo:footnote xsl:use-attribute-sets="fnt.footnote"> 
     <fo:inline baseline-shift="super"> 
      <axf:footnote-number id="fn_{@id}"/> 
     </fo:inline> 
     <fo:footnote-body space-after="1mm"> 
      <fo:list-block provisional-distance-between-starts="5mm" 
       provisional-label-separation="2mm"> 
       <fo:list-item> 
        <fo:list-item-label end-indent="label-end()"> 
         <fo:block> 
          <fo:inline baseline-shift="super"> 
           <axf:footnote-number-citation ref-id="fn_{@id}"/> 
          </fo:inline> 
         </fo:block> 
        </fo:list-item-label> 
        <fo:list-item-body start-indent="body-start()"> 
         <fo:block> 
          <xsl:apply-templates mode="content"/> 
         </fo:block> 
        </fo:list-item-body> 
       </fo:list-item> 
      </fo:list-block> 
     </fo:footnote-body> 
    </fo:footnote> 
</xsl:template> 
</xsl:stylesheet> 
+1

あなたは、これまで私たちにあなたが持っている、関連するXSLTを表示することができますか? –

答えて

1

これらの変更は、脚注に脚注が使用される最初の時間を生成し、ちょうど回目以降の番号を生成する:

<xsl:key name="fn" match="fn[exists(key('footnote', @id))]" use="@id" /> 
<xsl:key name="fn-first" match="fn[. is key('fn', @id)[1]]" use="@id" /> 
<xsl:key name="footnote" match="footnote" use="@id" /> 

<xsl:template match="fn[exists(key('footnote', @id))][. is key('fn-first', @id)]" 
    mode="content" 
    priority="7"> 
    <xsl:apply-templates select="key('footnote', @id)" 
     mode="content"> 
     <xsl:with-param name="number" select="count(preceding::fn[. is key('fn-first', @id)]) + 1"></xsl:with-param> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="fn[exists(key('footnote', @id))][not(. is key('fn-first', @id))]" 
    mode="content" 
    priority="7"> 
    <fo:inline baseline-shift="super"> 
     <xsl:value-of select="count(key('fn-first', @id)/preceding::fn[. is key('fn-first', @id)]) + 1"/> 
    </fo:inline> 
</xsl:template> 

<xsl:template match="footnote" mode="content" priority="5"> 
    <xsl:param name="number" select="count(preceding-sibling::footnote) + 1" as="xs:integer" /> 
    <fo:footnote xsl:use-attribute-sets="fnt.footnote"> 
     <fo:inline baseline-shift="super"> 
      <xsl:value-of select="$number" /> 
     </fo:inline> 
     <fo:footnote-body space-after="1mm"> 
      <fo:list-block provisional-distance-between-starts="5mm" 
       provisional-label-separation="2mm"> 
       <fo:list-item> 
        <fo:list-item-label end-indent="label-end()"> 
         <fo:block> 
          <fo:inline baseline-shift="super"> 
           <xsl:value-of select="$number" /> 
          </fo:inline> 
         </fo:block> 
        </fo:list-item-label> 
        <fo:list-item-body start-indent="body-start()"> 
         <fo:block> 
          <xsl:apply-templates mode="content" /> 
         </fo:block> 
        </fo:list-item-body> 
       </fo:list-item> 
      </fo:list-block> 
     </fo:footnote-body> 
    </fo:footnote> 
</xsl:template> 

fnの値をcount()に返すなど、もう少し整理してみてください。

axf:suppress-duplicate-footnoteaxf:footnote-numberの両方をどのように使用できるかについての私の他の回答を参照してください。重複は、同じページに重複がある場合にのみ抑制されます。

1

重複した脚注にもIDが重複しています。固有でないIDのエラーが処理中のaxf:suppress-duplicate-footnoteの途中にありました。

あなたはそれを参照fnに基づいて、各脚注のためのユニークなIDを生成し、脚注へのリンクを行っていない場合:

<xsl:template match="fn[exists(key('footnote', @id))]" mode="content" priority="7"> 
    <!--+ fn link 
    | 
    | basic fn (inline) link template. 
    | 
    +--> 
    <xsl:apply-templates select="key('footnote', @id)" mode="content"> 
     <xsl:with-param name="id" select="generate-id()" /> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="footnote" mode="content" priority="5"> 
    <xsl:param name="id" /> 
    <!--+ footnote 
    | 
    | basic footnote template. 
    | 
    +--> 
    <fo:footnote xsl:use-attribute-sets="fnt.footnote" axf:suppress-duplicate-footnote="true"> 
     <fo:inline baseline-shift="super"> 
      <axf:footnote-number id="{$id}" /> 
     </fo:inline> 
     <fo:footnote-body space-after="1mm"> 
      <fo:list-block provisional-distance-between-starts="5mm" 
       provisional-label-separation="2mm"> 
       <fo:list-item> 
        <fo:list-item-label end-indent="label-end()"> 
         <fo:block> 
          <fo:inline baseline-shift="super"> 
           <axf:footnote-number-citation ref-id="{$id}" /> 
          </fo:inline> 
         </fo:block> 
        </fo:list-item-label> 
        <fo:list-item-body start-indent="body-start()"> 
         <fo:block> 
          <xsl:apply-templates mode="content" /> 
         </fo:block> 
        </fo:list-item-body> 
       </fo:list-item> 
      </fo:list-block> 
     </fo:footnote-body> 
    </fo:footnote> 
</xsl:template> 
関連する問題