You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Kent Henneuse <k....@hitachissi.com> on 2003/07/28 19:47:04 UTC

Difference Function

I have been trying to do some tests with ExsltSets.difference()
and am a bit confused by the results.  I am just trying to mimic
Unix diff in a way where I get the changes with the appropriate
tree structure to the outside.  If I am going about this the
wrong way or there is a simpler way to do this in code please
let me know. Here is a code snipet of what I am attempting:

     DocumentBuilder builder = factory.newDocumentBuilder();
     documentA = builder.parse(_fileA);
     documentB = builder.parse(_fileB);

     NodeList childrenA = documentA.getChildNodes();
     NodeList childrenB = documentB.getChildNodes();
     NodeList result = ExsltSets.difference(childrenB, childrenA);
     // Print result to a file

Not very complicated.  Here is what I am seeing when I dump the
results though.

Example 1:  (What I expect to come out)
File A                 File B                  Result
<?xml version="1.0"?>  <?xml version="1.0"?>   <?xml version="1.0"?>
<A>		       <A>                     <A>
</A>		         <B>Test</B>             <B>Test</B>
		       </A>                    </A>


Example 2:
<?xml version="1.0"?>  <?xml version="1.0"?>   <?xml version="1.0"?>
<A>		       <A>                     <A>
   <B>Test</B>            <B>Test</B>              <B>Test</B>
</A>		       </A>                    </A>

****** I would have expected the output to have been an empty node
list but not the same thing that I input

Example 3:
<?xml version="1.0"?>  <?xml version="1.0"?>   <?xml version="1.0"?>
<A>		       <A>                     <A>
   <B>Test</B>            <B>Test</B>              <B>Test</B>
                          <C></C>                  <C></C>
</A>		       </A>                    </A>

****** Here I would have expected just this to come back:
<?xml version="1.0"?>
<A>
    <C></C>
</A>


   	Thanks,

	-Kent