Xquery 对彼此相关的项目进行分组
我正在使用 eXist Xquery。我被这个问题困扰了。
我有一个 20 个 xml 的集合,其内容如下:
1.123.15.200.xml
<element name="userID">P111</element>
<element name="folderUID">A1</element>
<element name="imageUID">IMG15234</element>
1.123.15.205.xml
<element name="userID">P115</element>
<element name="folderUID">A34</element>
<element name="imageUID">IMG15238</element>
等等...
一个用户可以有多个文件夹,一个文件夹可以有多个图像。 1 个 xml 等于 1 个图像数据。
for $x in distinct-values(collection('db/mapdb')//element[@name="userID"])
return
<group>
{
// This part is where I have issue, i have no idea what to write in within this portion?
}
</group>
输出:
<group>
<user>P111</user>
<folder id="A1">
<image>IMG15238</image>
<image>IMG16234</image>
<image>IMG23523</image>
</folder>
<folder id="A82">
<image>IMG132238</image>
<image>IMG42344</image>
<image>IMG242523</image>
</folder>
</group>
谢谢你。
I am using eXist Xquery. I am stuck with this issue.
I have a collection of 20 xml with content as per like below:
1.123.15.200.xml
<element name="userID">P111</element>
<element name="folderUID">A1</element>
<element name="imageUID">IMG15234</element>
1.123.15.205.xml
<element name="userID">P115</element>
<element name="folderUID">A34</element>
<element name="imageUID">IMG15238</element>
and etc...
A user can have multiple folders, and a folder can have multiple Images. 1 xml is equal to 1 image data.
for $x in distinct-values(collection('db/mapdb')//element[@name="userID"])
return
<group>
{
// This part is where I have issue, i have no idea what to write in within this portion?
}
</group>
Output:
<group>
<user>P111</user>
<folder id="A1">
<image>IMG15238</image>
<image>IMG16234</image>
<image>IMG23523</image>
</folder>
<folder id="A82">
<image>IMG132238</image>
<image>IMG42344</image>
<image>IMG242523</image>
</folder>
</group>
Thanks you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)