Here you go Victor. Its a standard method known as Meunchian Grouping which uses keys to group the source XML by CatType. If you're not familiar with this method there's a v good explanation here
http://www.jenitennison.com/xslt/gro...muenchian.html
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="ResponseByCat" match="xmlCodeResponse/xmlCategoryNode" use="CatType"/>
<xsl:template match="/">
<html>
<head>
<title>Muenchian Grouping Example</title>
</head>
<body>
<h3>Muenchian Grouping Example</h3>
<xsl:apply-templates select="xmlResponse/xmlCodeResponse/xmlCategoryNode[generate-id()=generate-id(key('ResponseByCat', CatType)[1])]">
<xsl:sort select="CatType" order="ascending"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="xmlCategoryNode">
<xsl:value-of select="CatType"/> |
<xsl:for-each select="key('ResponseByCat', CatType)">
<xsl:sort select="@Code" order="ascending"/>
<xsl:if test="position()=1">
<xsl:value-of select="@Code"/><br/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This produces the following output:
OB | 8I
OS | 6A
SU | 11
If you have any problems converting the output to the format you want, or indeed if you have any other questions about the stylesheet, just ask.
rgds
Phil