0

在 XSLT 2.0 中,我将 tei:xml 文档处理为 HTML。在此过程中,出于两个原因,我分两次输出脚注编号。

首先,通过选择附加/替换为<sup>(对于上标数字)的某些元素,在文本正文中添加数字。

其次,在页脚中,div我创建了一个包含各种注释的相同脚注编号的列表。

所有这一切都很好,这在很大程度上要感谢在SO 上收到的帮助。

但是在通过数百个文档进行测试时,我注意到了编号顺序的问题。

第一步以正确的顺序输出数字(第 9-45 行)。第二步以错误的顺序输出元素(第 73-99 行)。XSLT fiddle 在 HTML 视图中简单清晰地演示了这一点:https ://xsltfiddle.liberty-development.net/jyH9rNj

简单比较一下,输出是这样的

body footnote #        footnote div footnote #
     1                          3
     2                          1
     3                          2

我相信这是一个订单处理的问题,但是在尝试调整它之后modespriority我一直无法解决这个问题。它似乎与seg在给它一个数字之前移动元素有关......

非常非常感谢提前。

seg/@corresp注意:和的数量date最多只能出现一次<seg>note理论上可以出现多次。

4

1 回答 1

2

我认为您想将变量更正为

<xsl:variable name="footnote-sources" select="$fn-markers-added//tei:date[@type='deposition_date'] |                            
            $fn-markers-added//tei:note[@type='public'] | $fn-markers-added//tei:fn-marker"/>

因为您不再想对segs 进行编号,而是对fn-marker它们在中间步骤中已转换为的 s 进行编号。

然后你还需要将模板调整为

<!-- outputs each item to a <p> in footnote <div> -->
<xsl:template match="*[. intersect $footnote-sources]" mode="build_footnotes">
    <xsl:choose>    
    <xsl:when test="self::tei:date[@type='deposition_date']">
            <xsl:element name="p">
                <sup>
                    <xsl:number count="*[. intersect $footnote-sources]" format="1" level="any"/>
                </sup> this is the foo /date (that should be footnote #1)
            </xsl:element>
        </xsl:when>
        <xsl:when test="self::tei:fn-marker">
            <xsl:element name="p">
                <sup>
                    <xsl:number count="*[. intersect $footnote-sources]" format="1" level="any"/>
                </sup> this is the foo seg/@corresp (that should be footnote #3)
            </xsl:element>
        </xsl:when>  
        <xsl:when test="self::tei:note[@type='public']">
            <xsl:element name="p">
                <sup>
                    <xsl:number count="*[. intersect $footnote-sources]" format="1" level="any"/>
                </sup> this is the foo /note (that should be number footnote #2)
            </xsl:element>
        </xsl:when>

        <xsl:otherwise/>
    </xsl:choose>
</xsl:template>

这样https://xsltfiddle.liberty-development.net/jyH9rNj/1显示

1 this is the foo /date (that should be footnote #1)

2 this is the foo /note (that should be number footnote #2)

3 this is the foo seg/@corresp (that should be footnote #3)

显然,解释“这是 fooseg/@corresp现在有点误导,因为它实际上是fn-marker在转换步骤之前放置的。

于 2018-11-05T05:14:53.677 回答