United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6941869 XSL : Xalan transformer fails to process semicolumn symbol in a count() function correctly
JDK-6941869 : XSL : Xalan transformer fails to process semicolumn symbol in a count() function correctly

Details
Type:
Bug
Submit Date:
2010-04-07
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2010-11-25
Component:
xml
OS:
generic
Sub-Component:
javax.xml.transform
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u20
Fixed Versions:
6u22-rev (b09)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

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
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;
     }
 
     /**
                                     
2010-04-22
EVALUATION

Patch verified in jaxp 1.4.
                                     
2010-04-27



Hardware and Software, Engineered to Work Together