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

Re: How to speed up parsing ??

Subject: Re: How to speed up parsing ??
From: "Django (Oznog) Blais" <tech@xxxxxxxxxxx>
Date: Thu, 31 Jul 2003 13:30:03 -0400
speed up xslt
Hi,

Very good job Ashish!

You said "<xsl:value-of>  in preference to <xsl:apply-templates>"

What's about <xsl:copy-of> instead of  <xsl:value-of> ?

Thanks,
Django

----- Original Message ----- 
From: "Tengshe, Ashish" <Tengshe.Ashish@xxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, July 31, 2003 12:10 PM
Subject: RE:  How to speed up parsing ??


> Hi,
> Here is a thread that you might want to see
> http://sources.redhat.com/ml/xsl-list/2001-02/msg01730.html click on
'Thread Index' to see all responses.
> The general consensus from the Gurus seem to be that for-each is not
slower than apply-templates, just one needs to find out when it is
appropriate to use.
> One post even quotes the Apache website as saying "for-each is faster
because there is no template matching involved". I think you may need to
look in other places to increase performance.
>
> This may not be relevant to you but I thought I'd just post these
performance tips, you can see if any apply to you
> These are from noted author Michael Kay and other sources
>
> 1. Avoid repeated use of "//item". This is very expensive. Use an Xpath
expression that's as close to the exact one (that can identify the wanted
nodes) as possible.
> 2. Don't evaluate the same node-set more than once, save it in a variable.
> 3. Avoid <xsl:number> if you can. For example, by using position()
function.
> 4. Use <xsl:key>, for example to solve grouping problems. There is an
example of this in this document.
> 5. Avoid complex patterns in template rules. Instead, use <xsl:choose>
within the rule.
> 6. Be careful when using the preceding[-sibling] or following[-sibling]
axes. This often
>         indicates an algorithm with n-squared performance.
> 7. Don't sort the same node-set more than once. If necessary, save it as a
result tree fragment
>        and access it using the node-set() extension function.
> 8. To output the text value of a simple #PCDATA element, use
<xsl:value-of>
>         in preference to <xsl:apply-templates>.
> More...
> 1. Keep the source documents small. If necessary split the document first.
> 2. Keep the XSLT processor (and Java VM) loaded in memory between runs
> 3. If you use the same stylesheet repeatedly, compile it first.
> 4. If you use the same source document repeatedly, keep it in memory.
> 5. If you perform the same transformation repeatedly, don't. Store the
result instead.
> 6. Keep the output document small. For example, if you're generating HTML,
use CSS.
> 7. Never validate the same source document more than once.
> 8. Split complex transformations into several stages.
>
> More...
> · Follow good performance engineering practice: record the time a
stylesheet takes before and after making each change, and change it back if
it doesn't improve
> · Use small documents rather than large ones
> · Don't assume that the processor makes a particular optimization
> · Use variables for storing Xpath results, do not access same nodes again.
> · Use temporary trees (result tree fragments in XSLT 1.0)
> · A 10% improvement is considered industry benchmark to justify a
substantial change.
>
> More...from the Apache Website
> · Avoid using predicates in '*' patterns
> · Avoid using id/key-patterns
> · Avoid union expressions where possible
> · Sort stored node-sets once
> · Cache input documents
>
> Lastly,
> · Follow Design Patterns!
>
> Also, probably not logical at all, but I read on one forum that if this
guy used  <xsl:apply-templates select="*"/> instead of
<xsl:apply-templates/> the performance increased drastically. Just something
to try.
>
> Thanks,
> Ashish
>
>
>
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Dipesh
> Khakhkhar
> Sent: Wednesday, July 30, 2003 6:16 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to speed up parsing ??
>
>
> Hi,
>
> I would like to know how can i speed up parsing xml file.
> I am having huge xml file (approx 30-50 MB). I have written xsl to get
text
> out it. I am getting it properly but it is taking lotta time.
>
> I have used "apply templates " frequently to go to the respective node. As
per
> my knowledge "for-each" and "apply-templates" does the same thing and i
assume
> internally they must be working alike. WILL THERE BE SPEED ENHANCEMENT IF
I
> USE FOR-EACH INSTEAD OF USING APPLY_TEMPLATES.
>
> Or if you do programatically the same thing will i be achieving speed
> enhancement ??
>
> My current xsl is drastically slow. Pls give me some hints and suggestion
to
> enhance performance of my xsl processing.
>
> Eagerly waiting for reply.
>
> Regards,
> Dipesh
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 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.