[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: assigning sequence numbers to repeated tags.
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|