[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: giving key() a context (changes between XSLT 1.0 a

Subject: RE: giving key() a context (changes between XSLT 1.0 and 2.0)
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 3 Sep 2004 08:54:28 +0100
RE:  giving key() a context (changes between XSLT 1.0 a
>     ...
>     <xsl:variable name='auth' select='$biogs/key("biog", $name)'/>
>     ...
> 
>  </xsl:template>
> 
> That is, key() is used directly in the expression, and has its
> context supplied by the previous expression step.  Assuming I'm
> understanding all this correctly, then I like this approach more than
> the three arg key() call, because it seems to fit better with
> typical XSLT usage patterns.

There is actually one use case where the 3-argument approach is much more
convenient, namely when the second argument is a node in a different
document from the one you want to search:

select="key('k', @code, document('codes.xml'))"
> 
> The above, however, didn't work in my XSLT 1.0 processor.  No
> surprise, I guess.  No need for the for-each hack if you could do
> that.  But I've been looking around for a succint explaination of
> what exactly changed in XSLT 2.0 to make this possible, and I haven't
> been able to find it yet.

The change was actually in XPath 2.0, which now allows any expression on the
rhs of the "/" operator. XPath 1.0 restricted this to be an axis step.  
> 
> So I guess my questions are:
> 
>  * is it true that the above ($biogs/key( ...)) really is illegal in
>    XSLT 1.0?

Yes.
> 
>  * what restriction was relaxed to make this possible in XSLT 2.0?
> 

See above.

Michael Kay

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.