XSLT 1.0:在多个文档之间排序 [英] XSLT 1.0: sorting between multiple documents

查看:86
本文介绍了XSLT 1.0:在多个文档之间排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<xsl:for-each select="//filenames">
   <xsl:variable name="current_filename" select="."/>
   <xsl:for-each select="
     document(.)//someNode[not(
       . = document($current_filename/preceding-sibling::node())//someNode
     )]
   ">
      <xsl:value-of select="."/>
   </xsl:for-each>
</xsl:for-each>

在上面的代码(XSLT 1.0)中,我有一系列文档(//filenames),我想打开这些文档并从中选择一些节点,除非该节点的值等于所有先前文档中相同节点的值.

In the above code (XSLT 1.0), I have a series of documents (//filenames), which I want to open and select some nodes from, unless that node's value equals the value of a same node in all preceding documents.

要使其正常工作,我必须嵌套两个for-each循环,因为我必须将当前文档名称保存在变量中,以便选择其先前的同级兄弟($current_filename/preceding-sibling).

To get this to work I had to nest two for-each loops, because I have to save the current documents name in a variable in order to select its preceding sibling ($current_filename/preceding-sibling).

这一切都可行,但是由于我有两个嵌套循环,因此无法将所有文档中的结果节点排序,就好像这是一个大序列一样.现在,如果我将排序规则插入第一个for-each中,它将对每个文档的节点进行排序.

This all works, but since I have two nested loops, I'm unable to sort the resulting nodes from all documents as if it were one big sequence. It now sorts the nodes per document if I insert a sorting rule into the first for-each.

有人知道反正这种分类的方法吗?也许可以避免使用变量,从而避免for-each循环的嵌套?

Does anyone know a way to achieve this sorting anyway? Maybe a way to avoid having to use the variable and thus the nesting of for-each loops?

推荐答案

我已经找到了解决方法!

I've found out how to do this!

首先,只需选择所有节点并对它们进行排序,便可以过滤出我不想要的节点!因此,我更改了选择/排序的顺序.首先选择,然后进行排序是不可能的,但是反之亦然!谢谢您的输入:).

By first just selecting all nodes, and sorting them, I was able to then filter out the nodes I didn't want with ! So I changed the order of selecting/sorting. First selecting followed by sorting was impossible, but the other way around works fine! Thanks for your input though :).

这篇关于XSLT 1.0:在多个文档之间排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆