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

RE: More efficient way than following-sibling?

Subject: RE: More efficient way than following-sibling?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 21 Mar 2002 08:53:43 -0000
following sibling inefficient
> I am trying to find a more efficient way to determine if a node has
> siblings, and then access the next sibling.
>
> Currently, I am running the following XSLT code:
>
> <xsl:if test="$TheNode/following-sibling::node()">
>  <xsl:call-template name="GenericTemplate">
>   <xsl:with-param name="TheNode"
> select="$TheNode/following-sibling::*[1]"/>
>  </xsl:call-template>
> </xsl:if>
>
> However, this is very expensive, when it comes to large XML documents.
>

I think in Saxon the above would be very efficient indeed. Do you have
evidence that it is inefficient on your chosen processor, or are you just
guessing?

My only quibble is that you are mixing following-sibling::node() and
following-sibling::* - you should almost certainly use the same test in both
cases.

You might get a (very small) speed-up by using a variable:

<xsl:variable name="next" select="$TheNode/following-sibling::*[1]"/>
<xsl:if test="$next">
  <xsl:call-template name="GenericTemplate">
   <xsl:with-param name="TheNode" select="$next"/>
  </xsl:call-template>
</xsl:if>

or you might be able to turn your named template into a template rule with a
mode, so the whole thing then simplifies to:

<xsl:apply-templates select="$TheNode/following-sibling::*[1]"
mode="generic"/>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 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.