[Bug 5295] [XSLT 2.0] xsl:for-each-group: transitivity

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5295





------- Comment #3 from zongaro@ca.ibm.com  2007-12-19 20:52 -------
I suspect you intended to include a group-by attribute in your example in
comment #0 - probably as in the following:

      <xsl:for-each-group select="
         xs:float('1.0'),
          xs:decimal('1.0000000000100000000001',
          xs:double( '1.00000000001')" group-by=".">

I'm still not convinced that any change is needed in xsl:for-each-group.  The
description of the group-by attribute in the first item in the bulleted list in
section 14.3 says that "the items in the population are examined in population
order" and that "if there is already a group created to hold items having that
grouping key value, J is added to that group; otherwise a new group is created
for items with that grouping key value, and J becomes its first member."

Assuming that "having that grouping key value" was intended to imply comparison
using "eq" - that what the fourth paragraph of 14.2 seems to say - that would
mean the first value (1.0 of type xs:float) would be placed in the first group,
the second value (the decimal value 1.0000000000100000000001) would also be in
the first group (because it compares equal to the xs:float value 1.0, and the
third value (the double value 1.00000000001) would be placed in a second group,
because it does not compare equal to the grouping key of the first group - the
float value.

My argument hinges on the assumption that the grouping key for a group is the
grouping key for the first item in the group.  That's based on the fact that
the current-grouping-key function is defined that way.  That seems to me like a
reasonable assumption, but perhaps others would argue it's not justified.

Now, having said all that, it occurs to that if an item has two grouping keys
that are not the same value but equal according to the eq operator, we still
might have implementation-dependent behaviour.  Consider this example:

      <xsl:for-each-group select="
         xs:float('1.0'),
          xs:decimal('1.00000000001'"
         group-by="if (. instanceof xs:float) then (xs:float(.),xs:decimal(.))
                      else .">

Now the first value has grouping keys float 1.0 and decimal 1.0, and the second
value has the grouping key 1.00000000001 of type decimal.  The definition of
group-by says that "if two or more grouping keys for the same item are equal,
then the duplicates are ignored."  So if the implementation chooses the float
key value for the first item, there will be one group; if it choose the decimal
value, there will be two groups.

Received on Wednesday, 19 December 2007 20:52:12 UTC