
Muenchian grouping (or ''Muenchian method'', named after Steve Muench) is an
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algorithms are used as specificat ...
for grouping of
data
In the pursuit of knowledge, data (; ) is a collection of discrete values that convey information, describing quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted ...
used in
XSL Transformations v1 that identifies keys in the results and then queries all nodes with that key. This improves the traditional alternative for grouping, whereby each node is checked against previous (or following) nodes to determine if the key is unique (if it is, this would indicate a new group).
In both cases the key can take the form of an attribute, element, or computed value.
The unique identifier is referred to as a key because of the use of the 'key' function to identify and track the group variable.
The technique is not necessary in XSLT 2.0+, which introduces the new
for-each-group
tag.
General aspect of the transform
The method took advantage of XSLT's ability to index documents using a key. The trick involves using the index to efficiently figure out the set of unique grouping keys and then using this set to process all nodes in the group:
key('products-by-category', @category) = 1"> = 1>
Although the Muenchian method will continue to work in 2.0,
for-each-group
Is preferred as it is likely to be as efficient and probably more so. The Muenchian method can only be used for value-based grouping.
References
{{DEFAULTSORT:Muenchian Grouping
Grouping
XML-based programming languages