Xslt Antennahouse格式化程序如何处理引用的脚注?

Xslt Antennahouse格式化程序如何处理引用的脚注?,xslt,xsl-fo,saxon,footnotes,antenna-house,Xslt,Xsl Fo,Saxon,Footnotes,Antenna House,我正在使用xsl fo(Saxon xsl 2.0,AHF V6.2)开发pdf打印出版物 我的目标是自动编号脚注(不包括单个页面上的重复脚注),插入引用的静态文本元素中的文本 因此,基本上内联脚注(fn)引用静态脚注文本元素,创建内联编号,并在页面底部打印相应的脚注文本 <?xml version="1.0" encoding="UTF-8"?> <document> <chapter> <paragraph>some descripti

我正在使用xsl fo(Saxon xsl 2.0,AHF V6.2)开发pdf打印出版物

我的目标是自动编号脚注(不包括单个页面上的重复脚注),插入引用的静态文本元素中的文本

因此,基本上内联脚注(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>

一些描述。。。
有脚注的描述
有脚注的描述
一些描述。。。
有脚注的描述
这是脚注1的正文。
这是脚注2的正文。
这是脚注3的正文。
一章中重复的内联脚注必须根据它们所指向的脚注显示相同的数字

这就是结果应该是什么样子

是否有可能通过AHF脚注扩展和fo:footnote元素实现这些目标

如果我将AntennaHouse格式化程序扩展用于fn计数,那么它确实会产生奇怪的行为。他们会继续计算(1、2、3),而不是参考参考脚注的正确和当前编号

这是目前为止的XSL(只是相关的代码片段):


这些更改会在第一次使用脚注时生成脚注,并生成后续时间的数字:

<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 footnote
axf:footnote number
,以便仅当重复项位于同一页面上时,才会抑制重复项。

这些更改在第一次使用脚注时生成脚注,并仅为后续时间生成数字:

<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 footnote
axf:footnote number
,以便仅当重复项位于同一页面上时才抑制重复项。

重复的脚注也有重复的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>

重复的脚注也有重复的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>


您可以向我们展示您目前拥有的相关XSLT吗?您可以向我们展示您目前拥有的相关XSLT吗?