mardi 24 juin 2014

XQuery 1.0/2.0: Group Elements by Changing Attribute (Alternative to XQuery 3.0: Tumbling Window)


Vote count:

0




I'm trying to group Elements via changing attributes, this could be easily done with XQuery 3.0 Tumbling Windows, but I'm limited to XQuery 2.0.


The input looks like following:



<?xml version="1.0" encoding="UTF-8"?>
<root>
<value attr="a" no="1"/>
<value attr="a" no="2"/>
<value attr="b"/>
<value attr="a" no="3"/>
<value attr="b"/>
<value attr="b"/>
<value attr="a" no="4"/>
<value attr="a" no="5"/>
<value attr="b"/>
<value attr="a" no="6"/>
</root>


The required output is the following:



<?xml version="1.0" encoding="UTF-8"?>
<root>
<new>
<value attr="a" no="1"/>
<value attr="a" no="2"/>
</new>
<new>
<value attr="a" no="3"/>
</new>
<new>
<value attr="a" no="4"/>
<value attr="a" no="5"/>
</new>
<new>
<value attr="a" no="6"/>
</new>
</root>


asked 49 secs ago






Aucun commentaire:

Enregistrer un commentaire