【问题标题】:How to cite bibliography in XSL transformation of XML to HTML如何在 XML 到 HTML 的 XSL 转换中引用参考书目
【发布时间】:2015-01-08 16:52:46
【问题描述】:

问题:我想引用 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 转换来制作这种“类似地图”的关联呢?

【问题讨论】:

  • 编号规则是什么?参考书目是您正在处理的 XML 的外部文档吗?
  • 是的,参考书目来自PDF论文,上面的例子只是xml论文的一小部分。我想做的是将XML论文的内容(使用XSL)转换为HTML,我想让参考书目出现在文本中,就像我写的一样
  • 我尝试使用 xsl:key 来做到这一点,但这只会替换属于被引用对象的信息的引用,在这种情况下,是参考书目元素。
  • 引用 bititem 的 XML 输入是否具有属性或元素形式的任何 XML 标记?还是它只有纯文本 [1] 并且 XSLT 需要解析纯文本中的任何带有数字的方括号?

标签: html xml xslt


【解决方案1】:

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

<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>

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

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

【讨论】:

  • 我在 cite 和 bibitem 上都使用了相同的属性
  • 所以你可以使用&lt;xsl:apply-templates select="key('citebib', @bibid)" mode="cite"/&gt;
  • 喜欢这个? ` `
  • 什么意思?模板是否总是返回“[1]”?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-25
  • 2014-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多