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

Re: Are xsl:key's best going into the future?

Subject: Re: Are xsl:key's best going into the future?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 15 Mar 2002 15:32:49 +0000
xsltc xsl key
Hi Robert,

> In fact, if you want to get the incredible performance gains from
> XSLTC, they: [ Xalan's XSLTC team -
> http://xml.apache.org/xalan-j/xsltc/xsltc_performance.html ] warn
> that you should not use keys.
>
> Should keys be avoided?

Actually, what that document says is that keys shouldn't be used *in
patterns*. The example they give is:

<xsl:template match="key('key-name', 'some-value')">
  ...
</xsl:template>

Here, the template matches nodes that have the value 'some-value'
according to the key 'key-name'.

Assuming that the key is simply using the id attribute of elements:

<xsl:key name="key-name" match="*" use="@id" />

The equivalent key-lesss way to express such a pattern is something
like:

<xsl:template match="node()[@id = 'some-value']">
  ...
</xsl:template>

As you can see from the preceding performance tip on the same page,
using predicates within patterns is a bad idea for good performance
with XSLTC as well.

The reason that both of these patterns are discouraged is because they
are type-less matches. From their description, with both keys and the
predicates, XSLTC can't quickly work out what kind of nodes could be
matched by the pattern, so it has to look through the whole document
to work it out.

This use of keys to match nodes with patterns is very different from
using keys to *select* nodes with an expression. There's nothing on
the XSLTC performance page that indicates that keys shouldn't be used
to select nodes, so I don't see any reason not to use them in that
way. For example:

  <xsl:apply-templates select="key('some-key', 'some-value')" />

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.