I would like to take some XML document and merge all nodes on some level who have the same attribute value. For instance, if I have a document of this form,
<xml>
<books id="X">
<book name="Story"/>
<book name="Tale"/>
</books>
<books id="X">
<book name="Folklore"/>
<book name="Magic"/>
</books>
<books id="Y">
<book name="Harry Potter"/>
<book name="LotR"/>
</books>
</xml>
then I would like to be able to convert it to the following document:
<xml>
<books id="X">
<book name="Story"/>
<book name="Tale"/>
<book name="Folklore"/>
<book name="Magic"/>
</books>
<books id="Y">
<book name="Harry Potter"/>
<book name="LotR"/>
</books>
</xml>
If at all possible, I would very much like to multiple solutions. For instance both one using XSLT and one using some other language.