Subject: [xsl] Re: Re: how calculate sum(x*y) From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Mon, 7 Oct 2002 07:33:34 -0700 (PDT) |
--- Andrey Solonchuk <solo at ibis dot odessa dot ua> wrote: > Hello Dimitre, > > Monday, October 7, 2002, 12:54:36 PM, you wrote: > > Thanks, for advise? but I try both variant and > explored that > > <xsl:variable name="x"> > <xsl:for-each select="//data"> > <xsl:element name="ddd"> > <xsl:value-of select="x * y"/> > </xsl:element> > </xsl:for-each> > </xsl:variable> > <xsl:value-of select="sum(xalan:nodeset($x)/ddd)"/>* > > this variant vork mauch more faster than using FXSLT > may be I do something wrong, then correct me please Hi Andrey, No you're not doing anything wrong and your observations are correct. What I meant in my reply was that the "foldl" solution would be faster than the "zipWith" solution -- and this is true. I have run a series of experiments with xml files having different number of "data" elements. "foldl" consistently outperformed "zipWith", even though in the "zipWith" solution I used the XPath sum() function on the node-set containing the products. For example, for a source xml file with 10000 "data" elements, with MSXML4 on a 800MHz Pentium 3 the results are: "foldl": 13.019sec. "zipWith": 17.706sec. The version using xsl:for-each is faster than the "foldl" solution, because it uses explicit iteration and not recursion. For cases where explicit iteration can be used, and having everything approximately equal, the explicit iteration solution might be faster. This advantage may not exist when compared to a recursive solution using tail recursion (and run on an XSLT processor that recognises tail recursion and implements it as iteration (e.g. Saxon)). ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Effecient element "filter, Trevor Nash | Thread | [xsl] Applying XSLT to SAX Reader, Bruce McDougald |
RE: [xsl] 50 XSLT Tips and a Quiz, Michael Kay | Date | RE: [xsl] Order of template match, Michael Kay |
Month |