This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: sorting a variable that contains a nodeset
- From: "rafael vazquez" <rc_vazquez at hotmail dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 10 Jan 2002 18:38:14 +0100
- Subject: [xsl] Re: sorting a variable that contains a nodeset
- Reply-to: xsl-list at lists dot mulberrytech dot com
>Hi Rafael,
>
> > My problem is that I have to compare each 'ARTICULO' with the
> > following 'ARTICULO', but once they are sorted. For this, I think
> > the best solution is to store in a variable all the nodes
> > 'ARTICULO', sort them, and compare each of them with the following.
>
>The only way that you can do this in XSLT 1.0 is if you use a
>node-set() extension function to create a new document in which the
>ARTICULOs are in sorted order. You create the new document within a
>variable:
>
> <xsl:variable name="articulos">
> <xsl:for-each select="ARTICULO">
> <xsl:sort select="NOMBRE_FAMILIA"/>
> <xsl:sort select="NOMBRE_SUBFAMILIA"/>
> <xsl:sort select="DESCRIPCION_CORTA"/>
> <xsl:copy-of select="." />
> </xsl:for-each>
> </xsl:variable>
>
>Then convert that to a node set with an extension function that
>depends on what processor you're using, and check the following
>ARTICULO using the following-sibling:: axis. For example, if you're
>using MSXML, you do:
>
> <xsl:for-each select="msxsl:node-set($articulos)/ARTICULO">
> ...
> <xsl:if test="NOMBRE_FAMILIA =
> following-sibling::NOMBRE_FAMILIA[1]">
> ...
> </xsl:if>
> ...
> </xsl:for-each>
>
>My intuition tells me that you might be wanting to do this because you
>want to create groups of ARTICULO elements. If that's the case, then
>there are different (and more portable) ways to go about it, so let us
>know if that's what you're trying to do.
Hi Jeni! You said it! I want to group articles depending on its category and
subcategory to show them grouped in a table. I´d thank you your ideas!
_________________________________________________________________
Hable con sus amigos en línea, pruebe MSN Messenger: http://messenger.msn.es
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list