Bug #1430
closedNullPointerException if current-grouping-key() called when there is no current grouping key
100%
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
Updated by Michael Kay over 12 years ago
- Category set to XSLT conformance
- Status changed from New to Resolved
Updated by Michael Kay over 12 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.4.0.4
Updated by Max Zhaloba over 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
Updated by Michael Kay over 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.)
Updated by O'Neil Delpratt over 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