Please help, I’m an XSLT newbie and I’m trying to transform one XML format into another.
I need to extract unique attribute values and transform the values into a new format. The example XML below shows the original and new/target format.
I've spent ages trying to do this without any enjoy. Can anyone help out or give me some pointers?
Original format:
<base>
<level>
<level2 Name ="AA" value="1"/>
</level>
<level>
<level2 Name ="BB" value="2"/>
</level>
<level>
<level2 Name ="BB" value="3"/>
</level>
<level>
<level2 Name ="CC" value="4"/>
</level>
<level>
<level2 Name ="AA" value="5"/>
</level>
</base>
New format:
<base>
<levelNames>
<level level2Name ="AA"/>
<level level2Name ="BB"/>
<level level2Name ="CC"/>
</levelNames>
</base>
Thanks a lot.
Once again the Muenchian grouping technique appears to be the missing piece.
Fairly trivial problem for it, so I'll let you do your own work to get to grips with Muench.
XSLT Soln:
XSLT O/P:
Please create first xsl:key then u can use below code easily.
xsl:key name="levelName" match="level2" use="@Name"