|
Subject: Re: [xsl] XSLT Comparison of Two Trees From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Tue, 08 Sep 2009 20:35:33 +0200 |
I wish to compare two (xml tree) documents, a previous document and it's
current version. The previous tree looks like this: (the current tree
appears below this previous tree, the xsl - below that.)
If I could
A. Create a report of zip codes that were added
B. Create a report of zip codes that were deleted
C. Create a report of zip codes that were moved
D. Find the percentage difference of the <Total>####</Total>
information, using this algorithm: (currentTotal -
previousTotal)/previousTotal
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:param name="pv" select="'previous.xml'"/> <xsl:variable name="pdoc" select="document($pv)"/> <xsl:variable name="cdoc" select="/"/> <xsl:output indent="yes"/>
<new-codes>
<city name="All areas"/>
<city name="Total, California"/>
<city name="Alhambra">
<zip zipCode="11111"><!-- This zip code was added to Alhambra -->
<Total>1000</Total>
</zip>
</city>
<city name="American River"/>
<city name="Anaheim"/>
<city name="Antioch">
<zip zipCode="22222"><!-- This zip code was added to Antioch -->
<Total>5790</Total>
</zip>
</city>
<city name="Auburn">
<zip zipCode="33333"><!-- This zip code was added to Auburn -->
<Total>5790</Total>
</zip>
</city>
<city name="Bakersfield"/>
<city name="Bakersfield, East Hills"/>
</new-codes>
<moved-codes>
<city name="All areas"/>
<city name="Total, California"/>
<city name="Alhambra"/>
<city name="American River"/>
<city name="Anaheim">
<zip zipCode="95610"><!-- zip code was moved from American River to
Anaheim -->
<Total>5750</Total>
</zip>
</city>
<city name="Antioch"/>
<city name="Auburn">
<zip zipCode="95628"><!-- This zip code was moved from American River
to Auburn -->
<Total>7325</Total>
</zip>
</city>
<city name="Bakersfield"/>
<city name="Bakersfield, East Hills"/>
</moved-codes>
<deleted-codes>
<city name="All areas"/>
<city name="Total, California"/>
<city name="Alhambra"/>
<city name="American River">
<zip zipCode="95621">
<Total>7135</Total>
</zip>
</city>
<city name="Anaheim"/>
<city name="Antioch">
<zip zipCode="94505">
<Total>1575</Total>
</zip>
</city>
<city name="Auburn"/>
<city name="Bakersfield"/>
<city name="Bakersfield, East Hills"/>
</deleted-codes>Martin Honnen http://msmvps.com/blogs/martin_honnen/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] XSLT Comparison of Two Trees, Doug Franklin | Thread | RE: [xsl] XSLT Comparison of Two Tr, Doug Franklin |
| [xsl] XSLT Comparison of Two Trees, Doug Franklin | Date | RE: [xsl] XSLT Comparison of Two Tr, Doug Franklin |
| Month |