|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








