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

RE: Benefits of using xsl:key

Subject: RE: Benefits of using xsl:key
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 4 Nov 2009 19:35:36 -0000
RE:  Benefits of using xsl:key
> I have now made a new input file. I transformed the original 
> input fil to a new input file making all the id attribute 
> values unique, and also all the content unique. I then hand 
> edited the new file for 15 of the elements, making the 
> content the same for some other element.
> The transformation with Saxon HE, PE and EE  without using 
> xsl:key is now much faster, 4.5s, but, as a big surprise (to 
> me), the use of xsl:key has no influence on the 
> transformation speed still being 4.5s, and also the 
> optimization option in EE has no effect!

I thought I explained why that should be expected. Your match pattern
match="x[.=preceding::x]" is intrinsically very inefficient, but by chance
it was performing OK because the distance between duplicates was always
small. You have now increased the distance between duplicates, so the match
pattern becomes more expensive, and gives quadratic performance with
document size. 
> I'm a little confused. My conclusion is that xsl:key can make 
> a transformation faster in some situations. It very much 
> depends on data.

Using keys will only speed things up if you use them in a place where the
performance is critical. You now have very few duplicates, so you are not
executing the body of the template very often, so speeding it up gives very
little benefit. Instead you need to speed up the match pattern, which you
can do by rewriting it to use key(): I would suggest one template match="x[.
is key('k', current())[1]]" to match the first duplicate, and another
match="x" with lower priority to match the remaining duplicates.


Michael Kay

Current Thread


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.
First Name
Last Name
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.