After a first xsl transformation I have a xml output similar to the following one:
<?xml version="1.0" encoding="UTF-8"?>
<analysis type="1">
<file path="a.txt">
<line nb="23" found="true"/>
<line nb="36" found="true" count="2"/>
<line nb="98" found="true"/>
</file>
<file path="a.txt">
<line nb="100" found="false"/>
</file>
<file path="b.txt">
<line nb="10" found="false"/>
</file>
<!-- more file nodes below with different @path -->
</analysis>
But now I need to obtain a second output where file
nodes are merged if they have the same path
attribute as follows:
<?xml version="1.0" encoding="UTF-8"?>
<analysis type="1">
<file path="a.txt">
<line nb="23" found="true"/>
<line nb="36" found="true" count="2"/>
<line nb="98" found="true"/>
<line nb="100" found="false"/>
</file>
<file path="b.txt">
<line nb="10" found="false"/>
</file>
</analysis>
I don't know possible @path
values in advance.
I looked at multiple posts about nodes merging but could not find a way to do what I want. I'm lost with nodes grouping, keys, id generation... and only obtained error messages so far.
Could you please help me to get the 2nd output starting from the first one (with xls 1.0) ? And if you could provide some references (websites) where I could find explanations about such kind of transformations it would be really great.
Note : the @nb
attribute of two line
nodes of two file
nodes having the same @path
never collide, it is unique, i.e. this will never happen :
<?xml version="1.0" encoding="UTF-8"?>
<analysis type="1">
<file path="a.txt">
<line nb="36" found="true" count="2"/>
</file>
<file path="a.txt">
<line nb="36" found="true"/>
</file>
</analysis>
Thank you a lot for your help !