XSLT/Saxon - 将 key() 与 collection() 一起使用:Prolog 中不允许内容?



我在file:///Users/username/foopath有一个tei-xml文档的集合。我需要从 XSLT 2.0 转换访问这些文档以获取密钥。

我有一个密钥,应该在这些文档中搜索匹配项//tei:seg[@type='dep_event']/@corresp

因此,我为文档集合声明了一个变量:

<xsl:variable name="coll" 
select="collection('file:///Users/username/foopath')"/>

还有一个钥匙:

<xsl:key name="correspidkey" 
match="tei:seg[@type='dep_event' and @corresp]" 
use="@corresp"></xsl:key>

然后,我按如下方式对集合部署密钥(拒绝来自self::的任何不需要的返回(:

<xsl:variable name="correspvar" 
select="self::seg[@type='dep_event' and @corresp]/@corresp"/>
<xsl:value-of select="$coll/(key('correspidkey',$correspvar) 
except $correspvar)/upper-case(@id)" 
separator=", "/>
</xsl:element>
</xsl:when> 

撒克逊 HE 9.6.07 返回Content is not allowed in prolog,但我无法确定此错误的确切指示。如果我删除此行,则错误会消失,并且文件处理正常。也许我用钥匙使用collection()

非常感谢。

此错误是因为对collection()的调用选择了格式不正确的 XML 文件。可以 (a( 在集合 URI 中使用;select=*.xml或 (b( 使用;on-error=ignore筛选出非 XML 文件。

最新更新