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

Re: XPath equivalence question

Subject: Re: XPath equivalence question
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 01 Dec 2011 00:28:47 +0000
Re:  XPath equivalence question
On 30/11/2011 23:48, Graydon wrote:
Does

<xsl:template match="/A//B">

match exactly the same thing as

<xsl:template match="B[/A]">?
Yes, I think so.

My presumption is that the second form is preferable on efficiency grounds -- on simple table lookup versus whatever tree-structure the descendant axis search produces -- but I don't actually know.


Saxon actually has different implementations for the two cases (I've often thought of normalizing patterns so they would end up the same internally, but have never got around to it). But the logic of the two implementations is pretty well identical, and I would be very suprised if there is any measurable performance difference.

You seem to be basing you reasoning on some kind of hypothetical implementation model which has no resemblance to the way it's implemented in Saxon and may have little resemblance to any other product. In both cases, in Saxon, the test whether a node matches the pattern will start by asking whether it is an element named B, and then proceed by asking whether it has an ancestor named A that is a child of the root document node. In both cases, if you do an apply-templates that selects a node named C, this rule won't even be considered and will have no impact on the performance.

Michael Kay
Saxonica

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.