Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - RE: creating unique set w/ xsl [Thread Next] Re: creating unique set w/ xslTo: NULL Date: 10/1/2004 1:56:00 PM Thanks! This is perfect. How about if not just id attributes were used but
also attributes identified by the parent element to be unique e.g:
_______________________________________________
<foo>
<xs a="mappable" b="mappable" c="mappable" f="house" t="car"
p="notmappable">
<x id="11" a="1" c="2" house="home">
<x id="11" a="1" c="2" house="car">
<x id="11" a="1" c="2" house="dog">
</xs>
<ys j="mappable" k="mappable" l="foo" f="house" t="car" p="notmappable">
<y id="22" j="3" l="4" house="home">
</ys>
</foo>
_______________________________________________
to
_______________________________________________
<uniques>
<unique id="11"> <!-- from id="11" cus its an id attribute -->
<unique id="1"> <!-- from a="1" cus its "mappable" in parent's
attributes -->
<unique id="2"> <!-- from a="2" cus its "mappable" in parent's
attributes -->
<unique id="22"> <!-- from id="22" cus its an id attribute -->
<unique id="3"> <!-- from a="3" cus its "mappable" in parent's
attributes -->
</uniques>
_______________________________________________
withouth the comments ofcourse
"Mukul Gandhi" <MukulGandhi@d...> wrote in message
news:E5D67B45-AE74-4246-961B-78A4C2153964@m......
> 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 | |||
|
