[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: Jesper Tverskov <jesper.tverskov@xxxxxxxxx>
Date: Thu, 5 Nov 2009 17:45:38 +0100
Re:  Benefits of using xsl:key
To complete the picture, I followed MK's advice and went to XMark - An
XML Benchmark Project, http://www.xml-benchmark.org/downloads.html,
and downloaded the ready-made-document of a 100 MB to see xsl:key at
work on a more realistic dataset.

To make transformations from inside Oxygen it was necessary to set
-Xmx256m up to -Xmx700m in oxygen.bat.

I used the following stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <!-- List the names of persons and the number of items they bought.
            (joins person, closed_auction) -->
    <xsl:output indent="yes"/>

       <xsl:template match="/">
           <items>
        <xsl:for-each select="/site/people/person">
            <xsl:variable name="a"
                select="/site/closed_auctions/closed_auction[buyer/@person =
                current()/@id]"/>
            <item person="{name}"><xsl:value-of select="count($a)"/></item>
        </xsl:for-each>
           </items>
       </xsl:template>
</xsl:stylesheet>

Saxon Home Edtion: 1. test: 876.9s, 2.test: 911.1s
Enterprise Edition: 1. test: 13.2s, 2. test: 13.0s both using
Optimization level 10.
Enterprise Edition: 3. test: 549.5s, 4. test: 556.5s using
Optimization level 1 and 5!

In Saxon's documentation we can read: "currently all values other than
0 results in full optimization but this is likely to change in
future." I don't understand why optimization level 1 and 5 are not as
good as 10 considering the documentation,  and I don't understand why
someone would want less than full optimization?

I then used the stylesheet below using xsl:key:

Saxon Home Edition: 1. test: 12.8s, 2. test: 13.1
That is: xsl:key in Home Edition is as good as the build in
optimization level 10 in Enterprise Edition making xsl:key not
necessary in EE in most situations.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <!-- List the names of persons and the number of items they bought.
            (joins person, closed_auction) -->
    <xsl:output indent="yes"/>
    <xsl:key name="k" match="/site/closed_auctions/closed_auction"
use="buyer/@person"/>

       <xsl:template match="/">
           <items>
        <xsl:for-each select="/site/people/person">
            <xsl:variable name="a"
                select="key('k', @id)"/>
            <item person="{name}"><xsl:value-of select="count($a)"/></item>
        </xsl:for-each>
           </items>
       </xsl:template>
</xsl:stylesheet>

Cheers,
Jesper Tverskov
http://www.xmlplease.com

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.