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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--