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

XML到HTML的XSL转换中如何引用书目,html,xml,xslt,Html,Xml,Xslt,问题:我想引用XML文件中的参考书目,该文件使用XSL转换为HTML页面。参考书目定义如下: <bibliography> <bibitem bibid="b1"> <title>Genome-enabled development of DNA markers of ecology, evolution and conservation. Molecular Ecology 19</title>

问题:我想引用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">
        ...

这意味着我引用的是带有属性“b1”的bibitem。此外,参考文献[2]是指bibitem=“b2”等。但是如何使用XSL转换建立这种“类似地图”的关联呢?

假设您有一个类似于
的标记来在论文文本中插入引用,您可以执行以下操作:

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

[
]
在这种情况下,只需从父元素
元素的索引位置检索数字


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

编号规则是什么?参考书目是您正在处理的XML的外部文档吗?是的,参考书目来自一篇PDF论文,上面的示例只是XML论文的一小部分。我想做的是将XML论文的内容(使用XSL)转换为HTML,在HTML中,我想使参考书目的引用出现在文本中,就像我写的一样。我尝试使用XSL:key来实现这一点,但这只会替换属于被引用对象的信息的引用,在本例中,参考书目元素。引用bititem的XML输入是否有任何属性或元素形式的XML标记?或者它只包含纯文本
[1]
,XSLT需要解析纯文本中的任何带数字的方括号?[]我在cite和bibitem上使用了相同的属性,所以您可以像这样使用
?`[……”“什么意思?模板是否总是返回“[1]”?
<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>