Michael Müller-Hillebrand wrote:
Dear experts,
Recently I was quite unimpressed by the presentation of an Omnimark script requiring 32 seconds to make what seemed like a little change to a 2000 cells table. I said, this would be possible with XSL as well, and suddenly I found myself challenged.
 
I looked at your stylesheet and looked at the XML input.
Could you put up an output file and some description description of how 
you are calculating the widths you are providing to the table element in 
the CALS thingy?
It looks like you want to strip out /table/tbody/row/entry@width 
attributes, do some calculations based on them, and then create a new 
table with the resultant attributes, and copy all the row/entry into it 
without the @width attributes.
If that's right, can you describe the calculation on the @width 
attributes that are generating the attributes to the table?
I looked through the code, but it didn't jump out at me...
notes on the code in general:
It's a big program and I have a tendancy to think it's going in an 
innefficient direction mainly by having all templates except root be 
named and called explicitly with a whole lot of variables being passed 
from template to template.  In my limited experience, these slow down 
processing significantly.  Someday I'll look into engine source and find 
out more specifically.
Another suspicious piece that I've noticed is the calls like:
<xsl:variable name="random-nodes-r" select="document('')//*" />
<xsl:variable name="random-nodes-c" select="document('')//*" />
Which, (correct me if I'm wrong here), are making two extra copies of 
the entire document in a variable?  Do this enough time and your memory 
will be exhausted.
That said, what symptoms were you experiencing?
Were you transforming a 20KB file and noticing that your xslt engine 
took 500MB of RAM?
Is there a 'profiling' option for saxon to tell you where your script 
spent how much of its processing time?
The xsltproc engine has a --profile option to output such information.  
I've used that many times to decrease runtime of my older scripts by 
order(s) of magnitude.
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list