Subject: [xsl] Re: sorting a variable that contains a nodeset From: "rafael vazquez" <rc_vazquez@xxxxxxxxxxx> Date: Thu, 10 Jan 2002 18:38:14 +0100 |
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.
_________________________________________________________________ Hable con sus amigos en línea, pruebe MSN Messenger: http://messenger.msn.es
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem in xsl:for-each, jam | Thread | Re: [xsl] Re: sorting a variable th, Jeni Tennison |
Re: [xsl] Problem in xsl:for-each, Jeni Tennison | Date | RE: [xsl] use cases for d-o-e, Evan D. Lenz |
Month |