I want the output xml to have grouped for the element \'c\', according to the attribute \'f\'. Here is my input xml and the xslt. I want the group to occur only once and the ot
You can match elements and check whether there are any preceding siblings with the same
f
attribute in their
sub-elements. If there are, you've found a duplicate of a given f
value (an occurrence of a given f
value that is not the first occurrence of that value) and you can just override the identity template to skip the element:
An advantage of this solution is that it doesn't require any knowledge about key or ID generation; it just works with basic XPath axis features. However, it might get slightly more complicated when the elements to compare are not all on the same nesting depth/in the same relative element hierarchy.
P.S.: I removed the
element because I couldn't test it (my Xml processor claimed I can only use it if I pass a readable stream rather than a file), but feel free to re-insert it if it works for you.