[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: how calculate sum(x*y)
--- 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|