如何在 XML 到 HTML 的 XSL 转换中引用参考书目

How to cite bibliography in XSL transformation of XML to HTML

问题:我想引用 XML 文件中的参考书目,该文件使用 XSL 转换为 HTML 页面。参考书目定义如下:

<bibliography>
        <bibitem bibid="b1">
            <title>Genome-enabled development of DNA markers of ecology, evolution and conservation. Molecular Ecology 19</title>
            <authors>
                <author>Thomson, R. C.</author>
                <author>Wang, I. J.</author>
                <author>Johnson, J. R.</author>
            </authors>
            <date>2010</date>
            <other>2184-2195</other>
        </bibitem>
        <bibitem bibid="b2">
        ...

我的问题是,如何在 HTML 页面中用数字表示对 bibitem 的引用?例如:

"...and genes are molecular units of heredity that code a protein. [1] ...

这意味着我正在引用具有属性 "b1" 的 bibitem。另外,参考文献 [2] 表示 bibitem="b2" 等等。但是我怎样才能使用 XSL 转换建立这个 "map-like" 关联呢?

假设你有一个像 <cite bibref="b1" /> 这样的标签来在论文文本中插入参考文献,你可以这样做:

<xsl:template match="cite">
  <xsl:apply-templates select="key('citebib', @bibid)" mode="cite"/>
</xsl:template>

<xsl:template match="bibitem" mode="cite">
  <xsl:text>[</xsl:text>
  <xsl:number />
  <xsl:text>]</xsl:text>
</xsl:template>

在这种情况下,数字只是从 <bibitem> 元素在其 <bibliography> 父元素中的索引位置检索。

您还可以在从您声明的键中检索到的元素上使用应用模板。您还应该 post XSL 中的相关元素。