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

RE: XSL: For-Each Efficient or Not?

Subject: RE: XSL: For-Each Efficient or Not?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 1 Jul 2002 20:11:26 +0100
RE:  XSL: For-Each Efficient or Not?
> >
> > >m:apply[child::*[position()=1 and name()='factorof']]
> >
...
> 
> In this case, however, the processor does have to look at 
> every node since 
> each node has to provide the context for the evaluation of the 
> expression(s) in the predicate. I.e. how does it evaluate 
> name()='factorof' 
> without picking up the node whose name it's testing? It would 
> be a pretty 
> smart processor that had already thrown away all the nodes in 
> the wrong 
> position before it did that.

It's not that difficult. Saxon doesn't quite achieve this today but it
will in the next release (I just tested it).

X[position() = 1 and name()='factorof']

can be statically rewritten as

X[1][name()='factorof']

without too much difficulty. All you need to know is that the right-hand
operand of the "and" does not depend on current position (and you need
to be careful not to rewrite X[1 and 2] as X[1][2]).

Once you have done this rewrite, the standard (run-time) optimization
for X[1] is triggered, so you stop evaluating X after you've found the
first node that matches.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.