|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Creating unique groups
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="{@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
--- Dave Roe <david_roe@xxxxxxx> wrote:
> I have this XML representing 2 groups (spread across
> 4 group elements):
>
> <root>
>
> <group name="group1">
> <entry name="entry1" />
> <entry name="entry2" />
> </group>
>
> <group name="group1">
> <entry name="entry3" />
> </group>
>
> <group name="group2">
> <entry name="entry4" />
> <entry name="entry5" />
> </group>
>
> <group name="group2">
> <entry name="entry6" />
> </group>
>
> </root>
>
> What would be the best approach to turn it into the
> following output,
> where the name of the group is used as the
> identifier of what should be
> a unique group element?
>
> <root>
>
> <group name="group1">
> <entry name="entry1" />
> <entry name="entry2" />
> <entry name="entry3" />
> </group>
>
> <group name="group2">
> <entry name="entry4" />
> <entry name="entry5" />
> <entry name="entry6" />
> </group>
>
> </root>
>
> Right now, I just need someone to point me in the
> right direction to
> get me started.
>
> Thanks,
> /dave
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








