xsl-list
[Top] [All Lists]

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

2003-06-23 21:53:42
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



<Prev in Thread] Current Thread [Next in Thread>