如何";"缝合在一起";使用eXistdb



如何创建一个"单个";一个notes元素作为根节点,具有note元素的多个子节点的结果?

以下是eXide:中的查询

xquery version "3.0";

for $note in collection('/db/tmp')/note
return <notes>{$note}</notes>

其中输出为:

nicholas@mordor:~/flwor$ 
nicholas@mordor:~/flwor$ lynx http://localhost:8080/exist/rest/db/scripts/notes.xq --dump
<notes>
<note>
bar
</note>
</notes>
<notes>
<note>
foo
</note>
</notes>nicholas@mordor:~/flwor$ 
nicholas@mordor:~/flwor$ 

我如何才能获得一个文档,其中只有一个根元素notes,Firefox不会对此感到窒息?

集合中有两个文件foo.xmlbar.xml

XML必须只有一个根元素。此外,在不知道数据中的结构的情况下,我认为您希望获得所有notes,无论它们嵌套的深度如何。要实现这一点,请使用collection($col)//note

xquery version "3.1";

<notes>
{
for $note in collection('/db/tmp')/note
return $note
}
</notes>

xquery version "3.1";

<documents>
{
for $doc in collection('/db/tmp')/document()
return <notes>{$doc/note}</notes>
}
</documents>

最新更新