I wish this help you You are not far off, but have made a number of small mistakes.... You have missed out DCH from your XPath expressions. DCL is a child of DCH, not of HEAD You have two templates matching the same expression DSV_DESADV0103/HEAD/DCL/DCLDET (which won't match anything due to point 1 anyway). I think the first template should just match DSV_DESADV0103/HEAD any because otherwise the xsl:apply-templates inside it select anything anyway You are using @container_id in your expressions, but container_id is not an attribute, but a child node
Does that help If you are new to Muenchian grouping and don't understand the concept then I don't think it is a good idea starting a project with nested grouping and two keys. As for your problems to understand the predicate generate-id(.)=generate-id(key('keyInsptr',INSPTR)), it is just making sure the for-each processes the first item in each group based on the key value as the expression key('keyInsptr',INSPTR) finds all items of the same key value, the positional predicate key('keyInsptr',INSPTR) takes the first of those items and the generate-id check is just the XSLT/XPath 1.0 way of comparing the identity of two nodes (with XPath 2.0 you could just write [. is key('keyInsptr',INSPTR)] although you would use for-each-group instead). Thus the
wish helps you I know that there are a bunch of examples here on how to do Muenchian grouping, but I have been trying for quite some time and havent been able to get it. , Define a grouping key for the .