[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Sum of identical nodes

Subject: Re: Sum of identical nodes
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Wed, 20 Jul 2005 10:34:46 +0200
Re:  Sum of identical nodes
Hi,

Tempore 08:18:34, die 07/20/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Alvin Ng <ngkwangming@xxxxxxxxx>:

Each file in File1 and File2 have few hundreds nodes of <moid></moid>
and <mt></mt>. My biggest hindrance is how to recursively sum up each
node from each nodeset.

if the element structures in File1 and File2 are always the same, you can use something very simple:


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


<xsl:param name="file1" select="/"/>
<xsl:param name="file2" select="document('file2.xml')"/>

<xsl:template match="/">
<xml>
	<xsl:apply-templates select="$file1/xml/*" mode="merge"/>
</xml>
</xsl:template>

<xsl:template match="mt" mode="merge">
	<xsl:variable name="pos" select="position()"/>
	<xsl:copy>
		<xsl:value-of select="sum(. | $file2/xml/*[$pos])"/>
	</xsl:copy>
</xsl:template>

<xsl:template match="moid" mode="merge">
	<xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>


regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) "N N1N;N.N8N5N9N1 N:N1N9 ON? N;N,N4N9 ON,N=ON1 N2N3N1N/N=N?ON= N1OO ON,N=O "

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.