Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Benefits of using xsl:key

From: Jesper Tverskov <jesper.tverskov@-----.--->
To: xsl-list@-----.------------.---
Date: 11/5/2009 4:46:00 PM
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent