RE: [XSLT 2.0] Extra parameter for key()

# I agree with Dimitre that xsl:key and xsl:id should have the 
# same argument forms but I do question why this is needed (for 
# id() or key()) It is true that the XSLT1 for-each hack was 
# horrible but given that the
# XPath2 versions allow id() to be used within a path 
# expression and index the document current at that point, what 
# is gained by the new syntax. Isn't id("a",$somedocumentnode) 
# the same as $somedocumentnode/id("a") in the case when 
# $somedocumentnode is a single document node (and perhaps also 
# when it is not?)

It's almost the same. There are probably two reasonable justifications for
the extra argument

(a) the $doc/id(@x) approach isn't obvious to the average beginner

(b) the above changes the context node for "@x" which means you need to
introduce a variable to follow cross-document references.

I'm not personally overwhelmed by the weight of these arguments but I can
live with them.

Michael Kay

Received on Wednesday, 24 March 2004 16:51:34 UTC