将 xml 注释转换为 html 脚注

问题描述 投票:0回答:1

我想将 XML 中的注释转换为 HTML 中的脚注。以下脚本可以很好地完成工作:

<xsl:template match="tei:note">
        <sup>
            <a>
                <xsl:attribute name="href">
                    <xsl:text>#note</xsl:text>
                    <xsl:value-of select="@n" />
                </xsl:attribute>
                <xsl:value-of select="@n" />
            </a>
        </sup>
    </xsl:template>

但是,脚注也应该与 XML 中的注释标记中捕获的信息一起出现在 HTML 页脚中。我无法让这个工作。我是否应该编写另一个模板并将其应用到 XSL 文件顶部的页脚元素中,例如:

<xsl:template match="/tei:TEI">
        <html>
            <head>
                <!-- Transform teiHeader elements -->
                <xsl:apply-templates select="tei:teiHeader"/>
                <xsl:apply-templates select="tei:standOff"/>
            </head>
            <body>
                <hr />
                <!-- Transform text elements -->
                <p><h2>Transcription</h2></p><xsl:apply-templates select="tei:text"/>
            </body>
            <footer>
            <xsl:apply-templates select="tei:text/tei:body/tei:p/tei:footer"/>
            </footer>
        </html>
    </xsl:template>

如果是这样,这个模板应该是什么样子?

html xml xslt
1个回答
0
投票

是的,我认为您需要使用

apply-templates
两次,如果您希望第二次为您的笔记产生与第一次不同的输出,那么您需要使用
apply-templates
的模式和相关的匹配模板,请参阅
© www.soinside.com 2019 - 2024. All rights reserved.