Project

Profile

Help

Bug #1430

closed

NullPointerException if current-grouping-key() called when there is no current grouping key

Added by Michael Kay about 12 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2012-03-05
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

If the XSLT current-grouping-key() function is called when there is no current grouping key in the context, for example outside the scope of any xsl:for-each-instruction, then a NullPointerException occurs. The correct action is to return an empty sequence. A patch is being placed in Subversion.


Files

test.zip (641 Bytes) test.zip Max Zhaloba, 2012-07-19 13:46
Actions #1

Updated by Michael Kay about 12 years ago

  • Found in version set to 9.4
Actions #2

Updated by Michael Kay almost 12 years ago

  • Category set to XSLT conformance
  • Status changed from New to Resolved
Actions #3

Updated by Michael Kay almost 12 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.4.0.4
Actions #4

Updated by Max Zhaloba almost 12 years ago

Hi Michael,

I'm trying to call the current-grouping-key() function when grouping with group-starting-with method in Saxon-HE 9.4.0.4 and encountering a null pointer exception while xsl:for-eachg-group with group-by returns an empty sequence as expected. I'm not quite sure if it's correct to access current-grouping-key() in group-starting-with loop since in this case only the first item in a group corresponds to the grouping key and the rest do not.

The sample XML and XSLT files attached.

Thanks,

Max

Actions #5

Updated by Michael Kay almost 12 years ago

  • Status changed from Closed to Resolved
  • Fixed in version deleted (9.4.0.4)

Thanks for reporting. Yes: it appears the patch in 9.4.0.4 handled one case (calling current-grouping-key() when there is no current execution of xsl:for-each-group) but not this case, where there is a current activation of xsl:for-each-group but it uses group-starting-with or group-ending-with. A revised patch is being committed and will appear in the next maintenance release.

The effect of the patch is to do what the spec requires, which is to return an empty sequence (see section 14.2: "While an xsl:for-each-group instruction with a group-by or group-adjacent attribute is being evaluated, the current grouping key will be a single atomic value. At other times, it will be the empty sequence."

(The spec in fact isn't entirely clear what happens when an xsl:for-each-group using group-starting-with is nested dynamically within an xsl:for-each-group using group-by: does current-grouping-key get reset? I think it should be reset, and will propose a spec clarification to this effect.)

Actions #6

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 9.4.0.8

Bug now closed. Successfully applied to the Saxon 9.4.0.8 maintenance release.

Please register to edit this issue

Also available in: Atom PDF