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

RE: Slow Transformation

Subject: RE: Slow Transformation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 19 Nov 2008 19:40:23 -0000
RE:  Slow Transformation
The lack of indentation here makes it very hard to see the structure, but
I'll try.

<xsl:template match="/">

That's really sloppy HTML. If you're generating HTML using XSLT, there's
really no excuse for not making it something that at least approximates to
valid HTML.

<xsl:for-each select="pmr6sum/item[count(. | key('d-due',due)[1])=1]">

You're doing Muenchian grouping here. That doesn't by itself explain why the
performance is bad, but you would improve your code and perhaps make the
problem more visible by using xsl:for-each-group instead.

<xsl:for-each select="pmr6sum/item[count(. | key('c-code',ccode)[1])=1]">
  <xsl:for-each select="../item[count(. | key('d-due',due)[1])=1]">
    <xsl:value-of select="format-number(sum(../item[(ccode=$c-code) and
(due=current()/due)]/book),'########')" />

I think this is the heart of your problem. For each item (well, each
distinct item) you are processing ../item - that is, all the sibling items;
and for each of these you have another .//item which is again processing all
the sibling items. So if you double the number of items, your code will take
8 times as long: it's O(n^3).

I'm not inclined to suggest improvements to this code without first
understanding something about your data and the requirements your code is
designed to meet. 

Michael Kay

> -----Original Message-----
> From: Eugene Bernard [mailto:eugene.bernard@xxxxxxxxx] 
> Sent: 19 November 2008 07:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Slow Transformation
> Hi all,
> I am using the below xsl file to transform a xml file of size 
> approximately 3MB to a HTML file.
> The transformation takes more time...
> Can anybody help me to sort this out.
> Note : using java version "1.6.0_04" and saxon9

Current Thread


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.
First Name
Last Name
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.