posted 16 years ago
Hi Paul - Thanks for the reply. Please find my xsl below. What it does it merges category elements but now I don't know how to delete. Thank you.
<?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"/>
<xsl:template match="/groupsList">
<groupsList>
<xsl:call-template name="grpCategory"/>
</groupsList>
</xsl:template>
<xsl:template name="grpCategory">
<xsl:for-each select="/groupsList/category">
<xsl:call-template name="eachGroupCategory">
<xsl:with-param name="grpCat">
<xsl:value-of select="@name"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="eachGroupCategory">
<xsl:param name="grpCat" select="''"/>
<xsl:variable name="cnt" select="count(/groupsList/category[@name=$grpCat])"/>
<xsl:choose>
<xsl:when test="$cnt > 1">
<category>
<xsl:attribute name="name"><xsl:value-of select="$grpCat"/></xsl:attribute>
<xsl:copy-of select="/groupsList/category[@name=$grpCat]/node()"/>
</category>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/groupsList/category[@name=$grpCat]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
[ October 08, 2008: Message edited by: Artie Zero ]
[ October 08, 2008: Message edited by: Artie Zero ]