xsl-list
[Top] [All Lists]

Re: Sum of identical nodes

2005-07-20 01:34:46
Hi,

Tempore 08:18:34, die 07/20/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Alvin Ng <ngkwangming(_at_)gmail(_dot_)com>:

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)
"Η αλήθεια και το λάδι πάντα βγαίνουν από πάνω"

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>