[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: Peter Davis <pdavis152@xxxxxxxxx>
Date: Wed, 20 Mar 2002 13:36:47 -0800
peter davis capistrano
On Wednesday 20 March 2002 11:45, Michael Glick (B) wrote:
> 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.

You might try using the same test in the xsl:if as you use for the select in 
the xsl:with-param.  Perhaps the xsl:if is building a list of all of the 
following-sibling::node()s, even though in order to do that test you would 
only have to check that there is one following-sibling::node().

Also, I wonder why you test for node() in the xsl:if, and use * in the 
xsl:with-param.

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

If your processor isn't smart enough to only find the first following-sibling 
in the xsl:if, then the [1] will force it to do that.  Probably this is 
what's slowing you down in large documents.

Changing the node() to a * will also help in the future (or today?) with 
processors that can re-use the result of the first XPath expression when it 
finds a second that is exactly the same.  I think that XSLTC is planning to 
do this.

Are you sure that the problem is here?  Other than the missing [1], it seems 
like this would be a fairly innocent transformation.  If can do some 
profiling on the processor, it might help show where the problem is (or show 
that this solves it).

-- 
Peter Davis
That's the true harbinger of spring, not crocuses or swallows
returning to Capistrano, but the sound of a bat on a ball.
		-- Bill Veeck

 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.