Re: [xsl] Sorting a variable that contains a nodeset

Subject: Re: [xsl] Sorting a variable that contains a nodeset
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Jan 2002 16:23:03 +0000
Hi Rafael,

> I have a variable containing a nodeset as <xsl:variable name="var"
> select="//ARTICULO"/> and I want to order this nodeset by the node
> 'NOMBRE_FAMILIA'. How can I perform it? Exists any function that
> sorts the variable?

Because collections of nodes are *sets* in XSLT 1.0, they are
unordered by definition. But you can process the nodes in the set in a
particular order using xsl:sort when you use xsl:for-each:

  <xsl:for-each select="$var">
    <xsl:sort select="NOMBRE_FAMILIA" data-type="number" />
    ...
  </xsl:for-each>

Or when you apply templates:

  <xsl:apply-templates select="$var">
    <xsl:sort select="NOMBRE_FAMILIA" data-type="number" />
  </xsl:apply-templates>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread