Fantastic - that certainly does the trick, thank you.
Is there a way of extending this approach so that it can de-duplicate
entries?
For example, if I have:
<root>
<group name="group1">
<entry name="entry1" />
<entry name="entry2" />
</group>
<group name="group1">
<entry name="entry2" />
<entry name="entry3" />
</group>
</root>
and I want to end up with:
<root>
<group name="group1">
<entry name="entry1" />
<entry name="entry2" />
<entry name="entry3" />
</group>
</root>
(with producing 2 entries for entry2).
Thanks again,
/dave
On Dec 3, 2004, at 11:29 PM, Mukul Gandhi wrote:
Hi Dave,
Please try this XSL. It uses the Muenchian
technique.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="by-group-name" match="group"
use="@name" />
<xsl:template match="/root">
<root>
<xsl:for-each select="group[generate-id(.) =
generate-id(key('by-group-name', @name)[1])]">
<group name="{(_at_)name}">
<xsl:for-each select="key('by-group-name',
@name)">
<xsl:copy-of select="*"/>
</xsl:for-each>
</group>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--