xQuery 和 Saxon。对于参数的每个值一个新标签
我得到了以下示例 xml:
<meci>
<nodes>
<node id="x">
<mlfbs>
<region value="H">
<mlfblist>
<mlfb partno="1" masternode="false" />
<mlfb partno="2" masternode="false" />
</mlfblist>
</region>
</mlfbs>
</node>
</nodes>
</meci
我编写了以下 xQuery:
xquery version "1.0";
<ProductList>
{
for $a in /meci/nodes/node
return
<Product>
<id>{data($a/@id)}</id>
<mflb>{data($a/mlfbs/region/mlfblist/mlfb/@partno)}</mflb>
</Product>
}
</ProductList>
结果看起来像
<ProductList>
<Product>
<id>x</id>
<mflb>1 2</mflb>
</Product>
</ProductList>
但我想得到以下结果:
<ProductList>
<Product>
<id>x</id>
<mflb>1</mflb>
<mflb>2</mflb>
</Product>
</ProductList>
谁能告诉我我做错了什么?任何帮助将不胜感激,我已经搜索了几个小时但没有解决方案:/。
干杯 斯特凡
I got the following sample xml:
<meci>
<nodes>
<node id="x">
<mlfbs>
<region value="H">
<mlfblist>
<mlfb partno="1" masternode="false" />
<mlfb partno="2" masternode="false" />
</mlfblist>
</region>
</mlfbs>
</node>
</nodes>
</meci
And I have written the following xQuery:
xquery version "1.0";
<ProductList>
{
for $a in /meci/nodes/node
return
<Product>
<id>{data($a/@id)}</id>
<mflb>{data($a/mlfbs/region/mlfblist/mlfb/@partno)}</mflb>
</Product>
}
</ProductList>
The result looks like
<ProductList>
<Product>
<id>x</id>
<mflb>1 2</mflb>
</Product>
</ProductList>
But I'd like to get the following result:
<ProductList>
<Product>
<id>x</id>
<mflb>1</mflb>
<mflb>2</mflb>
</Product>
</ProductList>
Could anyone please tell what I am doing wrong? Any help would be much appreciated, I have been search hours with no solution :/.
Cheers
stefan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
再使用一个
for
来获取mflb
列表:Use one more
for
to getmflb
list: