0

以下是 2 个 XML DB 的示例结构 -

主题数据库

<Subjects>
 <Subject>Physics</Subject>
 <Subject>Biology</Subject>
 <Subject>Maths</Subject>
 <Subject>Algebra</Subject>
</Subjects>

分类数据库

<Classification>
 <Subject>Physics</Subject>
 <Subject>English</Subject>
 <Subject>History</Subject>
 <Subject>Algebra</Subject>
</Classification>

我需要将两个数据库中的不同值作为单个输出,并且像这样排序 -

 <Subject>Algebra</Subject>
 <Subject>Biology</Subject>
 <Subject>English</Subject>
 <Subject>History</Subject>
 <Subject>Maths</Subject>
 <Subject>Physics</Subject>
4

1 回答 1

3

经过一番反复试验,我能够获得所需的输出 -

let $items := ( doc("Subject")//Topic , doc("Classification")//Topic )
for $x in distinct-values($items )
   order by $x
   return <Subject>{$x}</Subject>

我很困惑在哪里放置distinct-values()以及如何一次打开两个文档。

于 2013-08-20T11:49:33.930 回答