[xsl] Re:Re: How to improve the performance where a key element used in multiple documents's

Subject: [xsl] Re:Re: How to improve the performance where a key element used in multiple documents's
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Mon, 25 Jun 2001 13:16:57 +0800
Hi, Jeni,

Thanks for taking time to look into my xsl and point out several redundant
logic in keeping using intermediate RTF and key element.

You specially suggest me to consider using predicates such as:

<xsl:variable name="MSource" select="$originalDoc/z:row"/>
  <xsl:apply-templates select="$MSource[@OrderNo = $thisNo]"
                       mode="transDtl" />

instead of using key element,

    <xsl:for-each select="$originalDoc">
      <xsl:apply-templates select="key('TransNo',$thisNo)"

As matter of fact I have tried using predicates, however its performance is
much slower compared with  that of  using key table.  So I decide
keep on using key function.

The following table summarize my testing results using 5 testing cases with
one xm structure,
it is interesting to see that results using predicates is too slowere to the
one using key function.
I wonder does it make sense to you and would you provide interpretations on
these results ?

Problem size                  process time by using method of
case unique set      total row records    key             predicates

 1   2960              10220          20 sec          11 min 20 sec
 2   1482               5047           6 sec           2 min 58 sec
 3   1507               6048           7 sec           3 min 37 sec
 4   1557               4411           5 sec           2 min 44 sec
 5   1742               5115           7 sec           3 min 28 see

The above summary is from using msxml 3  and ie5.5 , and using only a xml
document.   xsl is attached for your reference.

Sun-fu Yang


<?xml version="1.0" encoding='big5'?>
<?xml-stylesheet href="TransLogDtl-update.xsl" type="text/xsl"?>

<xsl:stylesheet version="1.0"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
exclude-result-prefixes="rs z msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="TransNo" match="z:row" use="@OrderNo" />
<!--  this extract the data from only one xml  value -->
<xsl:include href="normalized-rs.xsl"/>
<xsl:include href="date-time.xsl" />
<xsl:variable name="xmla" select="'TransLogDtl-01.xml'"/>

<xsl:variable name="sourceLine">
<xsl:call-template name="normalized-rs">
<xsl:with-param name="xmlfile" select="$xmla"/>
<xsl:variable name="originalDoc" select="msxsl:node-set($sourceLine)" />
<xsl:variable name="MSource" select="$originalDoc/z:row"/>

<xsl:variable name="TransNoheading"

<xsl:template match="/">
<xsl:value-of select="substring-before(substring-after($xmla,'-'),'.')"/> 月
Total Log No  = <xsl:value-of select="count($TransNoheading)"/>
Totalno  Data = <xsl:value-of select="count($MSource)"/>
Day:time<table><tr><xsl:call-template name="day-time"/></tr></table>>
<xsl:variable name="TransNox">
<xsl:for-each select="$TransNoheading">
 <xsl:sort select="@OrderNo"/>
<xsl:copy-of select="@*"/></z:row>
<xsl:for-each select="$TransNoheading">-->
<xsl:for-each select="$TransNoheading/@OrderNo">
<xsl:sort select="." data-type="number"/>

<xsl:variable name="thisNo" select="."/>

<caption>Transfer Activity Records  for OrderNo=<xsl:value-of

<!--xsl:apply-templates select="key('TransNo',$thisNo)"  mode="transDtl"-->
<xsl:apply-templates  select="$MSource[@OrderNo=$thisNo]" mode="transDtl">
<xsl:sort select="@ProdCode"/>

<table><tr><xsl:call-template name="day-time"/></tr></table>

<xsl:template match="z:row" mode="transDtl">
 <td><xsl:value-of select="position()"/></td>
 <td><xsl:value-of select="@OrderNo"/></td>
<td><xsl:value-of select="@FacilityID"/></td>
<td><xsl:value-of select="@ClientID"/></td>
<td><xsl:value-of select="@WareID"/></td>
<td><xsl:value-of select="@ProdCode"/></td>
<td style="align:right"><xsl:value-of
<td style="align:right"><xsl:value-of
select="format-number(@BeforeQty,'#,##0')" /> </td>
<td style="align:right"> <xsl:if test="string(@Amt)"><xsl:value-of
select="format-number(@Amt,'#,##0.00')" /></xsl:if> </td>
 <td style="align:right"><xsl:value-of
select="format-number(@BeforeAmt,'#,##0.00')" /></td>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread