We have problems with XSL transformations using the so-called Muenchian Method(by Steve Muench) for grouping nodes of an XML document (see also < http://www.jenitennison.com/xslt/grouping/muenchian.html> ). The Xalan transformer contained in the JDK 5 & 6 does not compile or evaluate the following union (= "|" symbol) expression in a count() function correctly - it always evaluates to 1 instead of the real number of nodes in the union set:
The problem is observed from JDK 5 update 12 onwards, including 6th and 7th trains.
More detailed explanation:
Xalan 2.6 contained in the Sun JDK 1.5 u12 and newer has issues with evaluating grouping nodes according the Muenchian Method, where nodes are stored in a key data structure for the group key, and later a group start is checked by checking for the first node retrieved for a key.
The nodes are compared using a set union, where the size of the set should be 1 when the nodes are identical, and different to 1 when the nodes are different.
The issue with Xalan 2.6 as part of the JDK is, that it does not evaluate the expression "count(.|key('props', subexpr))" correctly. It always returns "1". If the argument expression of count() is stored in a variable first, and the variable is used as argument for count(), then everything works fine.