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

RE: How to efficiently remove "a" nodes with no "b" de

Subject: RE: How to efficiently remove "a" nodes with no "b" descend ants
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 9 Mar 2001 10:32:54 -0000
RE:  How to efficiently remove "a" nodes with no "b" de
> If I say
>
> > <xsl:template match="a[not(.//b)]"/>
>
> then all the descendants of "a" are checked for "b" elements. Let's
> have a closer look at the input structure.

> This presupposes that the XSLT processor you are using does
> no optimisation, which may or may not be true.
>

Optimizers look for "quick wins", constructs that are used sufficiently
often to be worth treating specially, and I suspect this isn't one of them.

Generally, it's bad news to put a complex test like this into a match
pattern, because there is little alternative to testing each node selected
by <apply-templates> against this pattern; there is more scope to optimise a
node-set expression than a pattern.

You might find that a more efficient approach is

<xsl:variable name="ancestors-of-b" select="//b/ancestor::*"/>
<xsl:variable name="anc-of-b-count" select="count($ancestors-of-b)"
<xsl:template match="a">
<xsl:if test="count(.|ancestors-of-b) != $anc-of-b-count">
 ...

Mike 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.