Subject: Re: How to efficiently remove "a" nodes with no "b" descend ants
From: Teppo Peltonen <teppo.peltonen@xxxxxx>
Date: 08 Mar 2001 18:45:45 +0200
|
"FINLEY, Mike" <Mike.FINLEY@xxxxxxxxxx> writes:
Hello Mike,
> Why do you think your first offering is not "efficient"? I doubt
> you'll find anything more concise (one interpretation of efficient)
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.
> <a>
<!-- match, all descendants of "a" are checked -->
> <b/>
> <c/>
> <a>
<!-- match, all descendants of "a" are checked, again -->
> <a>
<!-- match, all descendants of "a" are checked, again -->
> <a>
<!-- match, all descendants of "a" are checked, again -->
> <c>
> <b/>
> </c>
> </a>
> <a>
<!-- match, all descendants of "a" are checked, again -->
and so on...
Instead of this, I would like to go straight to the far-most child of
the first "a" element and flag the sub nodes that have "b"
descendants, moving upwards in the tree. (Sorry, my algorythms are a
bit rusty right now, but I think there is a name for this kind of tree
traversing...) This way I need to examine each node only once.
Or maybe I am misunderstanding how XLST implements this? (Anyway, it
doesn't seem very speedy to me ;-).
> mike
Thanks for your comments,
Teppo
--
Teppo Peltonen <mailto:teppo.peltonen@xxxxxx> phone 09 4566080
VTT Information Technology mobile 040 5651878
Tekniikantie 4 B, P.O.Box 1201, Espoo 02044 VTT telefax 09 4567052
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|