p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: RE: TOO LONG TO TRANSFORM (KEY) CONTINUED WOW!!!


Message #1 by "Claudio Pallone" <pallone@l...> on Mon, 2 Sep 2002 23:14:54 +0100
Hi Michael,

Today I did not go to work but at 23:04 in the evening I opened my email and
saw your message and instructions. I decided to try it straight away and I
was in for a really nice surprise!!  WHAT AN IMPROVEMENT, THE IMPACT ON THE
SPEED IS TREMENDOUS. I was so excited. This is really amazing!!

I would really like to thank you for your time and effort. I was nearly
giving up and deciding that maybe it would be better to do all the
trasnformation on the server and save all the HTML files to be used later by
the users. But with this improvement I can go back on my previous idea of
generating the XML on the fly and using xslt to transform it to HTML on the
fly as well.

Again, this has been a major incentive for me to keep learning XSLT.

Many thanks

Claudio

Subject: RE: TOO LONG TO TRANSFORM (KEY) CONTINUED
From: "Michael Kay" <michael.h.kay@n...>
Date: Sun, 1 Sep 2002 13:27:22 +0100
X-Message-Number: 2

Thanks for sending the files. I did some experiments using Saxon.

Your stylesheet as supplied took 124.3 seconds - not too different from
the MSXML performance.

I defined a key:

<xsl:key name="c" match="Cell"  use="concat(@filterid, '/', @colid, '/',
@rowid)"/>

I changed the line:

<xsl:variable name="fs" select="key('k',
$ReportID)/Survey[@id=$SurveyID]/Cell[@colid=$CurrentColID and
@rowid=$CurrentRowID and @type=1 and @filterid=$FilterID]/DataValue">

to:

<xsl:variable name="fs" select="key('c', concat($FilterID, '/',
$CurrentColID, '/', $CurrentRowID))[@type=1 and ../@id=$SurveyID and
../../@id=$ReportID]/DataValue"/>

and the four lines:

<xsl:variable name="wgtd" select="key('k',
$ReportID)/Survey[@id=$SurveyID]/Cell[@colid=$CurrentColID and
@rowid=$CurrentRowID and  @type=1and @filterid=$FilterID]/DataValue"/>
<xsl:variable name="vert" select="key('k',
$ReportID)/Survey[@id=$SurveyID]/Cell[@colid=$CurrentColID and
@rowid=$CurrentRowID and  @type=2 and @filterid=$FilterID]/DataValue"/>
<xsl:variable name="horz" select="key('k',
$ReportID)/Survey[@id=$SurveyID]/Cell[@colid=$CurrentColID and
@rowid=$CurrentRowID and  @type=3 and @filterid=$FilterID]/DataValue"/>
<xsl:variable name="index" select="key('k',
$ReportID)/Survey[@id=$SurveyID]/Cell[@colid=$CurrentColID and
@rowid=$CurrentRowID and  @type=4 and @filterid=$FilterID]/DataValue"/>

to:

<xsl:variable name="cells" select="key('c', concat($FilterID, '/',
$CurrentColID, '/', $CurrentRowID))[../@id=$SurveyID and
../../@id=$ReportID]"/>
<xsl:variable name="wgtd" select="$cells[@type=1]/DataValue"/>
<xsl:variable name="vert" select="$cells[@type=2]/DataValue"/>
<xsl:variable name="horz" select="$cells[@type=3]/DataValue"/>
<xsl:variable name="index" select="$cells[@type=4]/DataValue"/>

This reduced the transformation time from 124.3 seconds to 7.5 seconds.

(This is not at all unusual - keys often give dramatic improvements like
this. My particular choice of key isn't critical, and I didn't
experiment with any others. Each value of the key I defined identifies a
group of four cells with types 1,2,3, and 4 respectively).

Michael Kay
Software AG
home: Michael.H.Kay@n...
work: Michael.Kay@s...




  Return to Index