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 5577 - [XSLT 2.1] Composite (multi-part) keys
Summary: [XSLT 2.1] Composite (multi-part) keys
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Windows XP
: 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: 2008-03-16 19:38 UTC by Michael Kay
Modified: 2011-06-08 20:32 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2008-03-16 19:38:26 UTC
We currently allow composite sort keys (sort first by surname, then given name), but we do not allow composite access keys (xsl:key) or grouping keys. Instead we require users to construct such keys by string concatenation, which is clumsy and error prone because the result may not be unique, and it prevents use of non-string types as keys.

The simplest way of defining a composite access key would be a new attribute <xsl:key composite="yes"/>. If the use expression is then multivalued, instead of indexing each item in the use expression as a separate key value, the sequence as a whole would be treated as a single key value, to be compared after atomization using deep-equal().

Alternatively we could adopt a syntax closer to that of xsl:sort, using one element for each component of the key.

Similarly for xsl:for-each-group we could add an attribute composite="yes", or we could allow multiple <xsl:group-by> children. 

The advantage of separate elements is that aspects such as collation can be defined separately for each component. The advantage of a composite="yes" attribute is that the number of components does not need to be known at compile time.
Comment 1 Michael Kay 2010-07-16 10:40:25 UTC
The WG wants to pursue the composite="yes" direction, implying that the values of the key are treated as sequences and compared as sequences. Noted that this could apply uniformly to xsl:key, group-by, xsl:sort, and xsl:merge-key.

Also noted, the idea that xsl:key could generate a function whose name is the key name, so in place of key('emp-by-name', 'Fred') one could write emp-by-name('Fred'), subject to issues about namespaces and backwards compatibility.
Comment 2 Michael Kay 2011-03-24 13:41:16 UTC
Current status: We have added composite="yes" to xsl:for-each-group and to xsl:key. Merge keys and sort keys already have the capability to be composite by using multiple xsl:sort or xsl:merge-key elements.
Comment 3 Michael Kay 2011-06-08 20:32:23 UTC
Closing this as fixed, on the grounds that we have added features to the spec that meet the requirement