Bug #3370


currentGroup / currentGroupingKey

Added by Michael Kay over 6 years ago. Updated about 6 years ago.

Start date:
Due date:
% Done:


Estimated time:
Applies to JS Branch:
1.0, Trunk
Fix Committed on JS Branch:
1.0, Trunk
Fixed in JS Release:
SEF Generated with:
Contact person:
Additional contact persons:


In the for-each-group code (compare.js line 966) appears:

unsortedGroupIter.forEachItem(function (groupInfo, pos) {
                groupInfo.sortKeys =
           (s) {
                        var f = unsortedGroupContext.focus;
                        f.current =[0];
                        f.position = pos + 1;
                        f.currentGroup =;
                        f.currentGroupingKey = groupInfo.key;
                        return Expr.evalChild1(s, unsortedGroupContext).next();

This is putting currentGroup and currentGroupingKey into the Tracker object (which is an iterator). However, in Expr.js line 472 and 480, we always get the values of currentGroup and currentGroupingKey from the Context object itself, not from the Tracker.

Actions #1

Updated by Michael Kay over 6 years ago

On the 2.0 branch, this is causing failures of tests such as for-each-group-007 where the groups are sorted by the value of current-grouping-key() - the test fails saying there is no current grouping key. Fixed on the 2.0 branch by changing the relevant lines of the above to:

                        unsortedGroupContext.currentGroup =;
                        unsortedGroupContext.currentGroupingKey = groupInfo.key;
Actions #2

Updated by Debbie Lockett over 6 years ago

Fix also committed on Saxon-JS 1.0 branch (in Compare.js). for-each-group-005 now passes, even if for-each-group-007 still doesn't.

Actions #3

Updated by Debbie Lockett over 6 years ago

  • Applies to JS Branch 1.0, Trunk added
Actions #4

Updated by Debbie Lockett over 6 years ago

  • Status changed from New to Resolved
  • Fix Committed on JS Branch 1.0, Trunk added

Test for-each-group-007 is now also passing. I'm not quite sure why I was seeing a failure but not anymore. I suspect one of the other recent bug fixes has done it.

Marking as resolved.

Actions #5

Updated by Debbie Lockett about 6 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 1.0.2

Bug fix applied in Saxon-JS 1.0.2 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page