[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] More efficient max() algorithm (Was: Re: Re: Max value
> <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> > <xsl:output indent="yes"/> > > <xsl:variable name="max"> > <xsl:for-each select="/table/row/col"> > <xsl:sort select="text()" data-type="number" order="descending"/> > <xsl:if test="position() = 1"> > <xsl:value-of select="text()"/> > </xsl:if> > </xsl:for-each> > </xsl:variable> This algorithm, as the one currently presented in the XSLT-FAQ, is O(N * Log2(N)) complex. There exists an O(N) algorithm -- look for it in the Jan/Feb threads of this group or in the generic templates download at vbxml.com. This algorithm uses simple recursion and may crash some XSLT processors. Another O(n) algorithm, which might be the fastest on a parallel processor environment and which has minimum recursion depth -- this is a Divide and Conquer algorithm for max(). Cheers, Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.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
|