help with Muenchian method grouping...
Here's my input xml...
<Collection>
<Content>
<Title>Portland</Title>
<root>
<Topic>Cities</Topic>
</root>
</Content>
<Content>
<Title>Tinyville</Title>
<root>
<Topic>Towns</Topic>
</root>
</Content>
...
</Collection>
Here's my desired output...
Cities
Albany
Portland
...etc...
Towns
Tinyville
Smithtown
...etc...
And here's my attempt thus far...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:key name="content-by-topic" match="Content" use="Topic"/>
<xsl:template match="/">
<xsl:if test="string-length(Collection/Content) > 0">
<h2>Websites</h2>
</xsl:if>
<xsl:template match="Collection">
<xsl:for-each select="Content[count(. | key('content-by-topic', root/Topic)[1]) = 1]">
<xsl:sort select="root/Topic" />
<xsl:value-of select="root/Topic" /><br />
<xsl:for-each select="key('content-by-topic', root/Topic)">
<xsl:sort select="Title" />
<xsl:value-of select="Title" /><br />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:template>
</xsl:stylesheet>
Unfortunately, as this is my first attempt with the Meunchian method, I've broken something... It's not working quite right for me.
Any ideas?
Thanks!!
|