[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Filling gaps in a list of values

Subject: Re: Filling gaps in a list of values
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Jan 2002 14:55:10 +0000
list of flawed 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

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:when test="position() = 1">
          <max><xsl:value-of select="@order" /></max>
        <xsl:when test="position() = last()">
          <min><xsl:value-of select="@order" /></min>

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" />



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.