Re: [xsl] Looping in XSLT(old question, but maybe new problem)

Subject: Re: [xsl] Looping in XSLT(old question, but maybe new problem)
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 23 Jun 2003 22:53:42 -0600 (MDT)
Liu Shuai wrote:
> As you see, I sort bar based on some rule, but when I get the next two
> element, how can I keep
> the order? Looks to me following-sibling fetch element based on the orginal
> order in the source
> file.

Yes, that's correct. The relationship between nodes has nothing to do with the
order in which they are processed. 

For this situation you are best off copying the nodes you need into a result
tree fragment, and converting it to a node-set with an extension function. If
your processor supports EXSLT (many do), then the exsl:node-set() function
(exsl prefix bound to "http://exslt.org/common";) will do the conversion. Other
and older processors support the same functionality with a vendor-specific
namespace and function name.

<xsl:variable name="bars-rtf">
  <xsl:for-each select="bar">
    <xsl:sort .../>
    <xsl:copy-of select="."/>
  </xsl:for-each>
</xsl:variable>
<xsl:variable name="bars" select="exsl:node-set($bars-rtf)"/>

<xsl:for-each select="$bars/bar">
  ...


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


Current Thread