Penguin
Note: You are viewing an old revision of this page. View the current version.

The MuenchianMethod is a technique in XSLT, which could probably also be applied to other data-centric FunctionalLanguages?.

In XSLT a common problem is how to fire an action exactly for each class of element seen. This is difficult in XSLT because it is a purely functional language and ``remembering'' that you've already seen an element of a class is impossible. There are certain highly recursive methods to solve the problem but these are incredibly inefficient, because (somewhat unusually for a functional language) XSLT is optimised not for recursion but application of templates to nodes in the XML tree.

The MuenchianMethod avoids this problem using a key defined to classify elements into a class. Keys in XSLT are like indexes in SQL---they are efficient.

The following creates a key called kName based on the name of each node. The template then matches only those nodes which are the first node in the key with that name.

... <xsl:key name="kName" match="*" use="name()"/> ... <xsl:template match="*[generate-id()

= generate-id(key('kName',

name() )[1?

)

]">

Element name: <xsl:value-of select="name()"/> <xsl:apply-templates/>

</xsl:template> ...

A good introduction to the MuenchianMethod: http://www.jenitennison.com/xslt/grouping/index.xml

lib/BlockParser.php:505: Notice: Undefined property: _tight_top (...repeated 2 times)