[xsl] The benefits of exact selection

Subject: [xsl] The benefits of exact selection
From: Jesper Tverskov <jesper@xxxxxxxxxxx>
Date: Fri, 6 Nov 2009 12:21:49 +0100
Hi list

We always hear that we should select as exactly as possible, and that
wildcards are inefficient. It makes sense.

But I'm tired of just telling it to my students so I set out to
construct a little transformation test that can demonstrate it in the
classroom.

I ended up with a million lines subdivided into 1050 children, each
having 140 children, each having 3 children. In what I believe is the
last element in document order, I might be wrong, I added a lonely
attribute with some value.

The two alternative select expressions are as follows:

1)
<xsl:value-of select="/document/colors[1050]/color[140]/dec/@num"/>
and
2)
<xsl:value-of select="//@num"/>

Using Saxon PE from inside Oxygen, I transformed 20 times for each.
Here is the average time as reported by Oxygen:

1) Exact selection: 4.1s
2) Wildcard selection: 5.0s

That is a difference. But it is also fair to say that for most
transformations, on a small dataset, it will be impossible to measure
a difference of any importance.

I would like to know about real life cases where removing not
necessary wildcard matching improved the transformation speed?

Cheers
Jesper Tverskov

http://www.xmlkurser.dk
http://www.xmlplease.com

Current Thread