Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - how to get unique set of node names [Thread Next] Re: how to get unique set of node namesTo: NULL Date: 8/5/2004 2:44:00 PM Hi Daniel,
Using Muenchian technique something like this...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="kDistinctElementNames" match="foo/*" use="local-name()"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="foo">
<xsl:copy>
<xsl:for-each select="*[generate-id() =
generate-id(key('kDistinctElementNames',local-name()))]">
<xsl:copy/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Although I suspect that that isn't really what you are after? Perhaps what
you are trying to do is build an output that has a summary structure
(excluding repetitions) of the input document? For example, what would you
want the output for the following XML to look like?...
<?xml version="1.0"?>
<foo>
<foo2/>
<bar>
<a/>
<a/>
<a/>
<b i="1"/>
<b i="1"/>
<c x="x">
<xxx a="1"/>
<xxx a="2"/>
<yyy b="1"/>
</c>
<c x="y">
<xxx a="3"/>
<yyy b="2"/>
</c>
<c x="z">
<yyy b="3"/>
<zzz c="1"/>
</c>
</bar>
</foo>
perhaps you are looking for an output something like?...
<?xml version="1.0"?>
<foo>
<foo2/>
<bar>
<a/>
<b/>
<c>
<xxx/>
<yyy/>
<zzz/>
</c>
</bar>
</foo>
If so, then this can be done - but gets pretty complex ;) But do say if
that's the end goal - I may have something that does that or about that.
Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Daniel" <softwareengineer98037@y...> wrote in message
news:%23yQwioNeEHA.1604@T......
> e.g. from:
> <foo>
> <a/>
> <a/>
> <a/>
> <b i="1"/>
> <b i="1"/>
> <c x="y">hello</c>
> <c x="y">hello</c>
> <c x="y">hello</c>
> </foo>
>
> I would like to get
>
> <foo>
> <a/>
> <b/>
> <c/>
> </foo>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
