Subject: Re: [xsl] 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 |
"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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to efficiently remove, Michael Kay | Thread | RE: [xsl] How to efficiently remove, FINLEY, Mike |
RE: [xsl] Saxon 6.21 TRAX interface, Michael Kay | Date | Re: [xsl] How to "quo" without "quo, Lindy Quick |
Month |