【发布时间】:2018-10-22 20:58:53
【问题描述】:
注意:更改了标题以更好地反映问题。
我的 xml 文档包含一个元素 <tei:seg @type @xml:id @corresp>,它包装了一些小“故事”。 @corresp 属性允许我将这些故事连接到一个主故事。比如这些seg都是由它们的@corresp连接的:
doc1.xml//seg[@type='dep_event' @corresp='#JKL' @xml:id='doc1-05']
doc2.xml//seg[@type='dep_event' @corresp='#JKL' @xml:id='doc2-06']
doc6.xml//seg[@type='dep_event' @corresp='#JKL' @xml:id='doc6-03']
我的目标是:当XSLT模板找到@corresp时,在其他具有相同@corresp的文档中找到其他seg并输出各自的`@xml:id`
所以,在上面的例子中,如果当前的seg是@xml:id='doc1-05',那么模板输出一个列表:Corresponds to doc2-06, doc6-03
直到我可以解决 eXist-DB 中的 current problems with XSLT collection() 之前,我将退回到我之前的解决方案:一个“TEI corpus”xml 文档,它通过 xi:include 维护所有相关 tei-xml 文档的主列表。这样,我提供了一个文档节点,处理器可以访问和搜索所有 xml 文档。
所以,我声明语料库文件:
<xsl:variable name="corpus" select="doc('ms609_corpus.xml')"/>
然后为@corresp 创建一个key:
<xsl:key name="correspkey" match="//tei:seg[@type='dep_event' and @corresp]" use="@corresp"/>
然后我使用带有doc() 的密钥进行搜索:
<xsl:when test="tei:seg[@type='dep_event' and @corresp]">
<xsl:variable name="correspvar"
select="data(self::seg[@type='dep_event' and @corresp]/@corresp)"/>
<xsl:text>Corresponds to </xsl:text>
<xsl:value-of select="data($corpus/(key('correspkey',$correspvar) except $correspvar)/@xml:id)" separator=", "/>
</xsl:when>
它返回结果,但except 应该排除当前的@corresp。但它包含在结果中。
【问题讨论】: