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

XML file compare problem

Subject: XML file compare problem
From: Kumar Shailendra <Kumar.Shailendra@xxxxxxxxxxxxxxxxx>
Date: Mon, 25 Jun 2001 03:33:07 -0500
xml file compare
Hi,
I am trying to take the difference between two xmls files using xalan2.0
extension function. Then print the difference as an xml file. I am
passing the second file as parameter to the stylesheet.
The problem I am facing is the xalan difference function is not giving
correct result. For testing purpose I passed as parameter the same file
as the input file to the stylesheet i.e. I compared "FileA" with "FileA"
but still none of the nodes were matching between two instances of the
same document source.
I tried Beyers Difference example from Dpawson's site but it also
returns the same result.
There seems to be some mistake in the way I am comparing the two files.
Since I am new to xml, I am handicapped with my limited understanding to
decypher the problem.
I would, therefore,  be grateful if some one can help me in overcoming
this problem.

The XML file I am trying to compare looks like the following

<?xml version="1.0" encoding="UTF-8" ?>
- <MSCIData>
- <row>
  <col Index="1" Value="850000000005152" />
  <col Index="2" Value="00020772338(\){;MF5A" />
  <col Index="3" Value="Atticus Capital Management, Inc." />
  <col Index="4" Value="590 Madison Avenue32nd Floor" />
  <col Index="5" Value="" />
  <col Index="6" Value="New York" />
  <col Index="7" Value="NY" />
  <col Index="8" Value="10022" />
  <col Index="9" Value="BRAZIL" />
  <col Index="10" Value="001 212 829 8100" />
  <col Index="11" Value="001 212 343 9489" />
  <col Index="12" Value="Y" />
  <col Index="13" Value="" />
  <col Index="14" Value="" />
  <col Index="15" Value="2001-05-04" />
  </row>
- <row>
  <col Index="1" Value="850000000005151" />
  <col Index="2" Value="00020772338(\){;MF5A" />
  <col Index="3" Value="Atticus Capital Management, Inc." />
  <col Index="4" Value="590 Madison Avenue32nd Floor" />
  <col Index="5" Value="" />
  <col Index="6" Value="New York" />
  <col Index="7" Value="NY" />
  <col Index="8" Value="10022" />
  <col Index="9" Value="BRAZIL" />
  <col Index="10" Value="001 212 829 8100" />
  <col Index="11" Value="001 212 343 9489" />
  <col Index="12" Value="Y" />
  <col Index="13" Value="" />
  <col Index="14" Value="" />
  <col Index="15" Value="2001-05-04" />
  </row>
  </MSCIData>

The stylesheet I am using to do the comparison is as follows ( I have
hard coded the second file in document function for testing purpose)


<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:xalan="http://xml.apache.org/xalan"
                              extension-element-prefixes="xalan"
                              exclude-result-prefixes="xalan">
<xsl:output method="xml"/>
<xsl:param name="comparison-file"/>
<xsl:variable name="file1" select="//*"/>
<xsl:variable name="file2"
select="document('file:///ms/user/s/shailend/playingzone/xml-java/compare1.xml',/)/*"
/>
<xsl:template match="/">
        <xsl:variable name="ns1" select ="$file1/*" />
        <xsl:variable name="ns2" select="$file2/*" />

Values in : nodeset1
        <xsl:for-each select="$ns1">
                "<xsl:copy-of select="."/>"
        </xsl:for-each>
===========================================

Values in : nodeset2
        <xsl:for-each select="$ns2">
                "<xsl:copy-of select="."/>"
        </xsl:for-each>
===========================================
difference:in $ns1, notin $ns2
        <xsl:for-each select="xalan:difference($ns1,$ns2)">
                "<xsl:copy-of select="."/>"
        </xsl:for-each>

===========================================
*******Xalan Intersection
        <xsl:for-each select="xalan:intersection($ns1,$ns2)">
                "<xsl:copy-of select="."/>"
        </xsl:for-each>

</xsl:template>
</xsl:stylesheet>

Thanks,
Shail


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.