0
基本上我在这里尝试的是使用XSLT通过引用XML中元素的值对多个XML进行合并和排序。根据另一个XML中的元素值对多个XML进行排序
> <xsl:variable name="refXml"
> select="document(concat(replace($refXmlTemp,'^file:',''),'/ref.xml'))"/>
>
>
> <xsl:for-each select="for $x in
> collection(string-join(($inputDir,'select=*.xml;recurse=yes;on-error=fail'),'?'))
> return
> (if (matches($refXml/root/descendant-or-self::issue/id[normalize-space(.)=normalize-space($x/art/item/id)]/number,'\w+')
> and matches($x/art/item/title,'\w+')) then saxon:discard-document($x)
> else())">
> <xsl:sort select="$refXml/root/descendant-or-self::issue/id[normalize-space(.)=/art/item/id]/following-sibling::number"/>
上面的代码片段合并了所有的输入XML,但它没有排序。
看来XSLT xsl:sort
函数只会在指向当前正在处理的XML内部的值时才起作用。
请指教我如何才能在排序中使用ref.xml作为参考。
这里ref.xml的一个样本输入端:
<root>
<issue>
<id>wlu-101</id>
<number>1</number>
</issue>
<issue>
<id>wlu-143</id>
<number>2</number>
</issue>
<issue-group>
<issue>
<id>wlu-144</id>
<number>3</number>
</issue>
<issue-group>
<issue>
<id>wlu-185</id>
<number>4</number>
</issue>
</issue-group>
</issue-group>
</root>
谢谢Martin,但是当我尝试你的建议代码时,它没有按照它应该的方式排序;它看起来在xml上没有任何更改。 – Viin
您是否可以尝试将问题减少到至少三个或四个您要按排序顺序处理的输入文件,并向我们展示样本,将其降至最低以展示问题?恐怕无法仅从您的XSLT代码片断中发现事情失败的情况,我们需要查看一些示例数据来确定哪个键或路径是错误的。 –
woot!这似乎是我的错,为什么它不适合我的第一次尝试,对不起。然而,后代或自己不能与一起工作,我们如何使用它来获得数字的价值?可能吗? –
Viin