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

Re: Slow XSLT

Subject: Re: Slow XSLT
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Sun, 2 Mar 2008 00:31:21 +0100
Re:  Slow XSLT
On 01/03/2008, Cleyton Jordan <cleytonjordan@xxxxxxxxxxx> wrote:
>  However, I thought that by using // followed by a
>  predicate ( //ColGrp[count(ancestor::ColGrp)=$depth]
>  ), I would go straight to only those inner most ColGrp
>  elements parent of the Col elements.
No, the XPath processor first has to find a ColGrp element by looking
into every corner of the input doc, and then check for the condition.

>  There is one problem with your approach though. You
>  are assuming that there will always be only two ColGrp
>  like this:
>
>  <xsl:for-each
>  select="/Reports/Report/Columns/ColGrp/ColGrp[count(ancestor::ColGrp)=$depth]">

I would propose a slightly different approach:
<xsl:for-each select="/Reports/Report/Columns/ColGrp">
   <xsl:apply templates mode="ColGrp"/>
</xsl:for-each>
passing the parameters needed for your processing and using only two
templates for ColGrp: one for the innermost ColGrp, and one for the
others
<xsl:templates match="ColGrp[Col]" mode="ColGrp">
processing for the innermost ColGrp here
</xsl:for-each>
<xsl:templates match="ColGrp" mode="ColGrp">
processing here (you can always test the depth with count(ancestor::ColGrp))
</xsl:for-each>
plus one for Col:
<xsl:templates match="Col" mode="ColGrp">
processing here
</xsl:for-each>

Another (simpler) approach would be to limit the maximum number of
dimensions for the table so you can use match patterns like
match="ColGrp"
match="ColGrp/ColGrp"
match="ColGrp/ColGrp/ColGrp"
match="ColGrp/ColGrp/ColGrp/ColGrp"
match="ColGrp[Col]"
match="Col"

Hope this helps,

Manfred

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.