[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Filling gaps in a list of values
Hi Ben, > Is it possible to sort the nodes and put them in a variable. ie > > <xsl:variable name="sorted"> > <xsl:for-each select="nodes[@order]"> > <xsl:sort select="@order" order="descending"/> > <xsl:copy-of select="current()"/> > </xsl:for-each> > </xsl:variable> > > (I know this doesn't work but could it work with the correct lines > of code? Or is it fatally flawed?) Yes, you can do this, but when you set a variable via its content then it gets set to a result tree fragment. To get any information out of the result tree fragment, you need to convert it to a node set using an extension node-set() function (whatever one your processor supports). This wouldn't be a bad method of getting the minimum and maximum values for the recursion, considering that you get both the minimum and maximum at the same time. You'd have to see, but it's likely that a recursive method (or even better, a built-in extension function) would be faster, but this is fairly simple. If I were doing it, I'd try to make the result tree fragment quite small, so simply make it: <xsl:variable name="minAndMax-rtf"> <xsl:for-each select="node[@order]"> <xsl:sort select="@order" order="descending" data-type="number" /> <xsl:choose> <xsl:when test="position() = 1"> <max><xsl:value-of select="@order" /></max> </xsl:when> <xsl:when test="position() = last()"> <min><xsl:value-of select="@order" /></min> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:variable> And then do: <xsl:variable name="minAndMax" select="exsl:node-set($minAndMax-rtf)/*" /> <xsl:call-template name="countDown"> <xsl:with-param name="from" select="$minAndMax/max" /> <xsl:with-param name="to" select="$minAndMax/min" /> </xsl:call-template> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.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
|