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)" mode="transDtl"/> </xsl:for-each> 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 sfyang@xxxxxxxxxxxxx <?xml version="1.0" encoding='big5'?> <?xml-stylesheet href="TransLogDtl-update.xsl" type="text/xsl"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:msxsl="urn:schemas-microsoft-com:xslt" 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:call-template> </xsl:variable> <xsl:variable name="originalDoc" select="msxsl:node-set($sourceLine)" /> <xsl:variable name="MSource" select="$originalDoc/z:row"/> <xsl:variable name="TransNoheading" select="$MSource[generate-id(.)=generate-id(key('TransNo',@OrderNo)[1])]"/> <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"/> <z:row> <xsl:copy-of select="@*"/></z:row> </xsl:for-each> </xsl:variable> <xsl:for-each select="$TransNoheading">--> <xsl:for-each select="$TransNoheading/@OrderNo"> <xsl:sort select="." data-type="number"/> <xsl:variable name="thisNo" select="."/> <table> <caption>Transfer Activity Records for OrderNo=<xsl:value-of select="$thisNo"/></caption> <thead><th>No</th><th>OrderNo</th><th>Facility</th><th>Client</th><th>WareID </th><th>ProdCode</th><th>Qty</th><th>Before</th><th>Amt</th><th>Before</th> </thead> <!--xsl:apply-templates select="key('TransNo',$thisNo)" mode="transDtl"--> <xsl:apply-templates select="$MSource[@OrderNo=$thisNo]" mode="transDtl"> <xsl:sort select="@ProdCode"/> </xsl:apply-templates> </table> </xsl:for-each> <table><tr><xsl:call-template name="day-time"/></tr></table> </xsl:template> <xsl:template match="z:row" mode="transDtl"> <tr> <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 select="format-number(@Qty,'#,##0')"/></td> <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> </tr> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re:Re:Question about using Xp, Yang | Thread | Re: [xsl] Re:Re: How to improve the, Jeni Tennison |
Re: [xsl] How to improve the perfor, Jeni Tennison | Date | [xsl] Problem with <xsl:import> and, Vijay Rao |
Month |