Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - creating unique set w/ xsl >Thread Next - Re: creating unique set w/ xsl RE: creating unique set w/ xslTo: NULL Date: 10/1/2004 10:31:00 AM This can be done with Muenchian grouping...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:key name="by-id" match="*" use="@id" />
<xsl:template match="/">
<uniques>
<xsl:for-each select="//*[@id][generate-id(.) =
generate-id(key('by-id', @id)[1])]">
<unique id="{@id}" type="{../@type}" />
</xsl:for-each>
</uniques>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
"Daniel" wrote:
> Using code i pull values from xml and put it into a hashes then put it back
> into xml to get the unique set. However, I was wondering if this was
> possible via xsl:
>
> ___________________________________________________
> <foo>
> <bars type="bartype">
> <bar id="1" x="a1" y="a2" z="3"/>
> <bar id="2" x="a11" y="a22" z="33"/>
> <bar id="1" x="a11111" y="a22222" z="33333"/>
> </bars>
> <houses type="housetype">
> <house id="7" a="a1" b="a2" c="a3"/>
> <house id="8" a="a1" b="a2" c="a3"/>
> <house id="9" a="a1" b="a2" c="a3"/>
> </houses>
> <bars type="bartype">
> <bar id="2" x="a111" y="a222" z="a333"/>
> <bar id="1" x="a1111" y="a2222" z="a3333"/>
> </bars>
> </foo>
> ___________________________________________________
> to
> ___________________________________________________
> <uniques>
> <unique id="1" type="bartype"/>
> <unique id="2" type="bartype"/>
> <unique id="7" type="housetype"/>
> <unique id="8" type="housetype"/>
> <unique id="9" type="housetype"/>
> </uniques>
> ___________________________________________________
>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
