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 17:58:08 +0100
- Subject: Re: [xsl] Sorting a variable that contains a nodeset
- Reply-to: xsl-list at lists dot mulberrytech dot com
>From: "cutlass" <cutlass@secure0.com>
>Reply-To: xsl-list@lists.mulberrytech.com
>To: <xsl-list@lists.mulberrytech.com>
>Subject: Re: [xsl] Sorting a variable that contains a nodeset
>Date: Thu, 10 Jan 2002 16:11:35 -0000
>
>Hello Rafeal,
>
>----- Original Message -----
>From: "rafael vazquez" <rc_vazquez@hotmail.com>
> > Hi All!
> > 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?
>
>depends on how you generate the variable, and if u want to use an extension
>function to continue manipulating it ( node-set() function that is).
>
>but since u didnt give me a snippet of xml that is representative, i cant
>really give u an explicit example...
>
>we would like to help,
>
>cheers, jim fuller
>
My XML file is:
<ALMACEN>
<ARTICULO>
<DESCRIPCION_CORTA>chuletas cerdo</DESCRIPCION_CORTA>
<DESCRIPCION_LARGA>chuletas cerdo extra</DESCRIPCION_LARGA>
<NOMBRE_FAMILIA>alimentacion</NOMBRE_FAMILIA>
<NOMBRE_SUBFAMILIA>carnes</NOMBRE_SUBFAMILIA>
</ARTICULO>
<ARTICULO>
<DESCRIPCION_CORTA>chuletas marrano</DESCRIPCION_CORTA>
<DESCRIPCION_LARGA>chuletas marrano extra</DESCRIPCION_LARGA>
<NOMBRE_FAMILIA>alimentacion</NOMBRE_FAMILIA>
<NOMBRE_SUBFAMILIA>verduras</NOMBRE_SUBFAMILIA>
</ARTICULO>
<ALMACEN>
And I want to show this information sorted in a HTML table. I perform this
with the code:
<xsl:template match="/ALMACEN">
<xsl:for-each select="ARTICULO">
<xsl:sort select="NOMBRE_FAMILIA"/>
<xsl:sort select="NOMBRE_SUBFAMILIA"/>
<xsl:sort select="DESCRIPCION_CORTA"/>
...
</xsl:for-each>
</xsl:template>
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 variable is formed as:
<xsl:variable name="nodos" select="//ARTICULO"/>
I hope you have enought information with it, otherwise I´ll be pleased to
give it to you.
Thanks friend!
_________________________________________________________________
MSN Photos es la manera más sencilla de compartir e imprimir sus fotos:
http://photos.latam.msn.com/Support/WorldWide.aspx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list