JDK-6941869 : XSL : Xalan transformer fails to process semicolumn symbol in a count() function correctly
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.transform
  • Affected Version: 6u20
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-04-07
  • Updated: 2012-04-25
  • Resolved: 2010-11-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
1.4.0Fixed 6u22-rev b09Fixed 7Fixed
Related Reports
Relates :  
Description
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:

 
        count(.|key('props', d/e)[1])

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)[1])" 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.

Comments
EVALUATION Patch verified in jaxp 1.4.
27-04-2010

SUGGESTED FIX This suggested fix has been verified with jdk 6 update 20 --- j2se/src/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBaseIterators.java Thu Jan 15 12:13:00 1970 +++ j2se/src/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBaseIterators.java Thu Jan 15 12:13:00 1970 @@ -2080,23 +2080,23 @@ //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); if (_isConstant) { _currentNode = _startNode; return resetPosition(); } else if (_isRestartable) { - if (_currentNode == Integer.MIN_VALUE) + //if (_currentNode == Integer.MIN_VALUE) { _currentNode = _startNode = node; } return resetPosition(); } return this; } /**
22-04-2010