I have a xsl template that groups items by their category. Now i want to group them together inside those categories.
my xsl script:
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:variable name="prefix_param">udt_<xsl:value-of select="//udt:Context/udt:ModuleId" />_param</xsl:variable>
<xsl:key name="data-by-Category" match="udt:Data" use="udt:Category" />
<xsl:template match="udt:Data" mode="list">
<li>
<xsl:value-of select="udt:Subcategory" disable-output-escaping="yes" />
<xsl:value-of select="udt:Information" disable-output-escaping="yes" />
</li>
</xsl:template>
<xsl:template match="/udt:UserDefinedTable">
<xsl:for-each select="udt:Data[count(. | key('data-by-Category', udt:Category)[1]) = 1]">
<xsl:sort select="udt:Zap" />
<span>
<h1>
<xsl:value-of select="udt:Category" disable-output-escaping="yes" /> </h1>
</span>
<xsl:variable name="currentData" select="key('data-by-Category', udt:Category)" />
<xsl:if test="$currentData">
<ul>
<xsl:apply-templates select="$currentData" mode="list">
<xsl:sort select="udt:PodCategory" order="ascending" />
</xsl:apply-templates>
</ul>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="EditLink">
<xsl:if test="udt:EditLink">
<a href="{udt:EditLink}">
<img border="0" alt="edit" src="{//udt:Context/udt:ApplicationPath}/images/edit.gif" />
</a>
</xsl:if>
</xsl:template>
The sample output i get now:
<h1>Category 1</h1>
<ul>
<li>Subcategory 1 info 1</li>
<li>Subcategory 2 info 1</li>
<li>Subcategory 2 info 2</li>
<li>Subcategory 2 info 3</li>
</ul>
<h1>Category 2</h1>
<ul>
<li>Subcategory 1 info 1</li>
<li>Subcategory 1 info 2</li>
<li>Subcategory 2 info 1</li>
</ul>
And this is the sample output i want to achieve:
<h1>Category 1</h1>
<h2>Subcategory 1</h2>
<ul>
<li>info 1</li>
</ul>
<h2>Subcategory 2</h2>
<ul>
<li>info 1</li>
<li>info 2</li>
<li>info 3</li>
</ul>
<h1>Category 2</h1>
<h2>Subcategory 1</h2>
<ul>
<li>info 1</li>
<li>info 2</li>
</ul>
<h2>Subcategory 1</h2>
<ul>
<li>info 1</li>
</ul>
I want to gtoup the items inside each group in a secondary group and display its title aswell.