This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 2916 - [XSLT] Which key is the grouping key for the group
Summary: [XSLT] Which key is the grouping key for the group
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 2.0 (show other bugs)
Version: Candidate Recommendation
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 18:16 UTC by Joanne Tong
Modified: 2006-03-13 11:10 UTC (History)
0 users

See Also:


Attachments

Description Joanne Tong 2006-02-22 18:16:37 UTC
Consider this example,

<xsl:for-each-group select="xs:float(1.0),1.0000000000100000000001,xs:double
(1.00000000001)" group-adjacent=".">
   <xsl:value-of select="current-grouping-key() instance of xs:float"/>
</xsl:for-each-group>

The grouping keys for each adjacent pair of items are equal using the eq 
operator, so all the values are in the same group.  However, the description 
of the group-adjacent attribute does not make it clear which of the three 
grouping keys is the grouping key for the group.

The description of the group-by attribute contains an algorithm that would 
make the key of the initial item to be the grouping key of its group.  

I suggest adding explicit text in the description of the group-adjacent 
attribute (and maybe even the group-by attribute) that the key of the initial 
item should be the group key of its group.
Comment 1 Michael Kay 2006-03-10 21:27:46 UTC
The WG considered this on 9 March 2006 and decided:

(a) the grouping key should be the value as it appears on the first item in the group

(b) however, if the grouping key was an untyped atomic value and was converted to a string, the value of current-grouping-key() is the string, not the untyped atomic value.

The editorial changes to implement this decision have not yet been made so the status is set to FIXED but not CLOSED.
Comment 2 Michael Kay 2006-03-13 11:10:44 UTC
The changed text to implement this decision is as follows:

In the definition of grouping key (immediately after XTSE1090) change: "The grouping key is the value of the expression contained in the group-by attribute or group-adjacent attribute." to "The grouping keys are the items in the sequence obtained by evaluating the expression contained in the group-by attribute or group-adjacent attribute, atomizing the result, and then casting any xs:untypedAtomic values to xs:string."

In 14.2 (current-grouping-key function) add after the third para.

Although the grouping keys of all items in the group are by definition equal, they are not necessarily identical. For example, one might be an xs:float while another is an xs:decimal. The current-grouping-key() function is defined to return the grouping key of the *initial item* in the group, after atomization and casting of xs:untypedAtomic to xs:string.