Subject: RE: [xsl] assigning sequence numbers to repeated tags. From: "Elovirta Jarno (NBI/Espoo)" <Jarno.Elovirta@xxxxxxxxx> Date: Thu, 17 Jan 2002 10:08:25 +0200 |
Hi, > I need to loop through all repeated tags (with the same > attrib number) and add a number reference to the attrib value. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="ISO-8859-1" indent="no"/> <xsl:key name="attrib" match="tag" use="@attrib" /> <xsl:template match="tag"> <xsl:copy> <xsl:attribute name="attrib"> <xsl:value-of select="@attrib" /> <xsl:if test="count(key('attrib', @attrib)) > 1"> <xsl:variable name="current" select="@attrib" /> <xsl:text />[<xsl:number count="tag[@attrib = $current]" />]<xsl:text /> </xsl:if> </xsl:attribute> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Will do it. There are probably more efficient ways of doing it, hope this helps in writing them. Santtu XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] assigning sequence numbers to, Edward . Middleton | Thread | [xsl] attribute question, Kevin . Gutch |
[xsl] Stange behavior with paramete, Gunther Schadow | Date | RE: [xsl] attribute question, Bryan Rasmussen |
Month |