Package org.exolab.adaptx.xml
Class XMLDiff
- java.lang.Object
-
- org.exolab.adaptx.xml.XMLDiff
-
public class XMLDiff extends java.lang.Object
A utility class used to compare two XPathNodes, or XML input files and report the differences between them.- Version:
- $Revision: 4322 $ $Date: 2004-04-20 02:29:32 +0200 (Tue, 20 Apr 2004) $
- Author:
- Keith Visco
-
-
Constructor Summary
Constructors Constructor Description XMLDiff()
Default Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.String url1, java.lang.String url2)
Compares the two XML documents located at the given URL locations.int
compare(XPathNode node1, java.lang.String filename1, XPathNode node2, java.lang.String filename2)
Compares the given XPathNodes.int
compare(XPathNode node1, XPathNode node2)
Compares the given XPathNodes.static void
main(java.lang.String[] args)
main method, for command line invocationvoid
setIgnoreChildOrder(boolean ignoreOrder)
Sets the flag for whether or not the order of element children should be ignored.void
setIgnoreWhitespace(boolean ignoreWhitespace)
Sets the flag for whether or not "ignorable" whitespace should in fact be ignored.void
setReturnOnFirstDifference(boolean returnOnFirst)
Sets the flag for whether or not to return immediately upon first difference found.
-
-
-
Method Detail
-
compare
public int compare(java.lang.String url1, java.lang.String url2) throws java.io.IOException
Compares the two XML documents located at the given URL locations. Returns 0, if no differences are found, otherwise returns a positive number indicating the number of differences.- Parameters:
url1
- the location of the XML document to compare.url2
- the location of the XML document to compare against url1.- Returns:
- 0, if no differences are found, otherwise a positive number indicating the number of differences.
- Throws:
java.io.IOException
-
compare
public int compare(XPathNode node1, XPathNode node2)
Compares the given XPathNodes. Returns 0, if no differences are found, otherwise returns a positive number indicating the number of differences.- Parameters:
node1
- the XPathNode to compare with.node2
- the XPathNode being compared against node1.- Returns:
- 0, if no differences are found, otherwise a positive number indicating the number of differences.
-
compare
public int compare(XPathNode node1, java.lang.String filename1, XPathNode node2, java.lang.String filename2)
Compares the given XPathNodes. Returns 0, if no differences are found, otherwise returns a positive number indicating the number of differences.- Parameters:
node1
- the XPathNode to compare with.node2
- the XPathNode being compared against node1.- Returns:
- 0, if no differences are found, otherwise a positive number indicating the number of differences.
-
setIgnoreChildOrder
public void setIgnoreChildOrder(boolean ignoreOrder)
Sets the flag for whether or not the order of element children should be ignored. By default this value is true, indicating that element ordering is not important. If order is important, set this value to false.- Parameters:
ignoreOrder
- a boolean that when true indicates that child order is not important.
-
setIgnoreWhitespace
public void setIgnoreWhitespace(boolean ignoreWhitespace)
Sets the flag for whether or not "ignorable" whitespace should in fact be ignored. By default this value is "true", indicating that all ignorable whitespace is ignored.- Parameters:
ignoreWhitespace
- a boolean that when true indicates that all ignorable whitespace should in fact be ignored. If false, then differeces in whitespace will be reported.
-
setReturnOnFirstDifference
public void setReturnOnFirstDifference(boolean returnOnFirst)
Sets the flag for whether or not to return immediately upon first difference found. This is useful when using the diff tool just to determine if two XPathNodes or files are XML-equivalent without enumerating all the differences.- Parameters:
returnOnFirst
- the boolean that when true indicates that the diff should terminate immediate upon first difference.
-
main
public static void main(java.lang.String[] args)
main method, for command line invocation- Parameters:
args
- an array of arguments
-
-