[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: Teppo Peltonen <teppo.peltonen@xxxxxx>
Date: 09 Mar 2001 19:19:47 +0200
Re:  How to efficiently remove "a" nodes with no "b" de
"Michael Kay" <mhkay@xxxxxxxxxxxx> writes:

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

Yes, I agree. I really shouldn't make assumptions about the
implementation of the processor. However, when things get slow, I have
to come up with something....

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

This looks really great! Create a set of all ancestors of all "b"
nodes and then check for each node "a" if it belongs to the set? I
wrote this like this:

<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">
      <a>
         <xsl:apply-templates/>
      </a>      
   </xsl:if>
</xsl:template>

But, unfortunately I don't seem to be able to get it working right
now... For some reason Xalan always claims that
count(.|$ancestors-of-b) is 1. Hmm... have to look at it again
later. Can anybody spot any obvious typos or something?

> Mike Kay

Thank you very much,

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


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.