|
Subject: RE: [xsl] Slow Transformation From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 19 Nov 2008 19:40:23 -0000 |
The lack of indentation here makes it very hard to see the structure, but
I'll try.
<xsl:template match="/">
<html>
<h4>Report</h4>
<body>
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
http://www.saxonica.com/
> -----Original Message-----
> From: Eugene Bernard [mailto:eugene.bernard@xxxxxxxxx]
> Sent: 19 November 2008 07:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Slow Transformation, Martin Honnen | Thread | [xsl] XTRE1160: The fragment identi, Andrew Welch |
| Re: [xsl] XTRE1160: The fragment id, Andrew Welch | Date | RE: [xsl] xsl:function vs. xsl:temp, Michael Kay |
| Month |