首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >脚注替换至本章末尾

脚注替换至本章末尾
EN

Stack Overflow用户
提问于 2014-01-27 13:37:48
回答 1查看 111关注 0票数 0

在输入的xml中,每个部分的每个段落都没有脚注。我想设置一个链接,其中脚注是可用的,我需要将所有脚注移至本章末尾的html。

供您参考,我正在粘贴我的输入部分。

代码语言:javascript
复制
<section level="1">
<heading class="hdgautonum1" level="1"><inline style="\-ilx-tab-stops: left blank 0tw; "><gentext type="headingnumberstring">1  </gentext>Introduction</inline></heading>
<par class="para"><inline class="glossaryrefmain">ITIL</inline> is part of a suite of best-practice publications for <inline class="glossaryrefmain">IT service management</inline> (ITSM).<inline class="footnote&#160;reference"><footnote>
<par class="footnote&#160;text"> ITSM and other concepts from this chapter are described in more detail in Chapter 2.</par></footnote></inline> ITIL provides guidance to <inline class="glossaryrefmain">service provider</inline>s on the provision of quality</par>
</section>

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-28 05:43:59

尝试以下模板:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <!-- copies all nodes -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <!-- generate footnote link -->
    <xsl:template match="footnote">
        <xref>
            <xsl:attribute name="rid">fn<xsl:number level="any" format="1"/></xsl:attribute>
            <xsl:number level="any" format="1"/>
        </xref>
    </xsl:template>

    <!-- removes container footnote&#160;reference, or you can retain them, just remove the comment marks o xsl:copy -->
    <xsl:template match="inline[contains(@class, 'footnote')]">
        <!--<xsl:copy>
            <xsl:copy-of select="@*"/>-->
        <xsl:apply-templates/>
        <!--</xsl:copy>-->
    </xsl:template>

    <!-- moves all footnotes at the end -->
    <xsl:template match="section">
        <root>
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <xsl:apply-templates/>
            </xsl:copy>
            <footnote-group>
                <xsl:apply-templates select="//footnote" mode="group"/>
            </footnote-group>
        </root>
    </xsl:template>

    <!-- template to fix footnotes, in a different mode -->
    <xsl:template match="footnote" mode="group">
        <footnote>
            <xsl:attribute name="id">fn<xsl:number level="any" format="1"/></xsl:attribute>
            <label><xsl:number level="any" format="1"/></label>
            <xsl:apply-templates/>
        </footnote>
    </xsl:template>

</xsl:stylesheet>

当应用于输入XML时,它输出:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<root>
    <section level="1">
        <heading class="hdgautonum1" level="1">
            <inline style="\-ilx-tab-stops: left blank 0tw; "><gentext type="headingnumberstring">1
                </gentext>Introduction</inline>
        </heading>
        <par class="para"><inline class="glossaryrefmain">ITIL</inline> is part of a suite of
            best-practice publications for <inline class="glossaryrefmain">IT service
                management</inline> (ITSM).<xref rid="fn1">1</xref> ITIL provides guidance to
                <inline class="glossaryrefmain">service provider</inline>s on the provision of
            quality</par>
    </section>
    <footnote-group>
        <footnote id="fn1">
            <label>1</label>
            <par class="footnote text"> ITSM and other concepts from this chapter are described in
                more detail in Chapter 2.</par>
        </footnote>
    </footnote-group>
</root>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21382314

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档