Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Reduce duplicate XML-nodes with XSLT-transformation

From: "Joris Gillis" <roac@-------.-->
To: NULL
Date: 3/1/2005 4:36:00 PM
Tempore 23:19:38, die Monday 28 February 2005 AD, hinc in foro {microsoft.public.xsl} scripsit Andreas Ek <google@a...>:

> I would like to reduce duplicate nodes in my XML-source.

>
> I would like to "optimize" this to something like:
> Just like som kind of group by in SQL ;-)

Hi,

If you only need optimization for one level you can use simple grouping techniques in XSLT1.0; if you need a more universally working solution, let us know.

Here's a working sample using the muenchian grouping technique:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" />

<xsl:key name="Paper" match="Paper" use="Code"/>

<xsl:template match="Root">
	<xsl:apply-templates select="Paper[generate-id()=generate-id(key('Paper',Code))]"/>
</xsl:template>

<xsl:template match="Paper">
	<xsl:copy>
			<xsl:copy-of select="Code | key('Paper',Code)/Price"/>
	</xsl:copy>
</xsl:template>

</xsl:stylesheet>




regards,
-- 
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Et ipsa scientia potestas est"  - Francis Bacon , Meditationes sacrae


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent