Subject: [xsl] Not-repeated elements in an <xsl:for-each> From: "Caranthir Morifinwë" <caranthir@xxxxxxxxxxxx> Date: Mon, 22 Dec 2003 00:48:07 +0100 (Hora estándar romance) |
I wonder if there is some way to get a list of nodes without repeated elements, something similitar to de "DISTINCT" clausule in a SELECT sentence of SQL. I need to do this because i want to show the total sum of many attributes from many elements. There is an example xml: <root> <ship type="astropod" num="100"/> <ship type="spider" num="150"/> <ship type="astropod" num="50"/> </root> If I use the following XSL template: <xsl:template match="/root"> <xsl:for-each select=ship/@type> <xsl:variable name="stype" select="."/> <xsl:value-of select="sum(/root/ship[@type=stype]/@num)"/> </xsl:for-each> </xsl:template> i get "150 150 150", repeating the third ship who has the same type than first. Is there any way to only get one "astropod" type in the list xsl:for-each iterates? XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] output CDATA in xml using, Michael Kay | Thread | Re: [xsl] Not-repeated elements in , G. Ken Holman |
RE: [xsl] output CDATA in xml using, Michael Kay | Date | Re: [xsl] Not-repeated elements in , G. Ken Holman |
Month |