Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] XSL: For-Each Efficient or Not?

From: "Michael Kay" <michael.h.kay@------------>
To:
Date: 7/1/2002 11:09:00 AM
> >
> > >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


transparent
Print
Mail
Digg
delicious
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