Basex XQL merging content with same tag name, regardless of location in document



For example, given XML:



<root>
<item>
<id>111</id>
<description>aisle 12, shelf 3</description>
<description>inside the box</description>
</item>
</root>


I would like the result:



<root>
<item>
<id>111</id>
<description>aisle 12, shelf 3 inside the box</description>
</item>
</root>


But the node may have any name, and be at any level. I would like the same query to work with different XML, as long as the tag is repeated:



<root>
<item>
<id>112</id>
<attributes>
<author>Joe Smith</author>
<author>Arthur Clarke</author>
<author>Jeremiah Wright</author>
</attributes>
</item>
</root>


Output:



<root>
<item>
<id>112</id>
<attributes>
<author>Joe Smith Arthur Clarke Jeremiah Wright</author>
</attributes>
</item>
</root>


Is this possible with BaseX ? If not, can we do this given a known element (for example, only for /root/item/attributes/author)?


No comments:

Post a Comment