Subject: Re: [xsl] Sorting a variable that contains a nodeset From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 10 Jan 2002 17:27:16 +0000 |
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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting a variable that c, cutlass | Thread | Re: [xsl] Sorting a variable that c, rafael vazquez |
Re: [xsl] Problem in xsl:for-each, jam | Date | Re: [xsl] Problem in xsl:for-each, Jeni Tennison |
Month |