Oracle9i Supplied Java Packages Reference Release 2 (9.2) Part Number A96609-01 |
|
This chapter documents package oracle.xml.differ for XML Diff Bean. This package is part of the Oracle XDK for Java Beans.
This chapter contains these sections:
The classes contained in oracle.xml.differ implement the XML Diff Bean, which performs a comparison on two XML DOM trees using a graphical user interface. A node can be inserted, deleted, moved, or modified.
You can generate the differences between the two XML trees in the form of XSL code. The first XML file can be transformed into the second XML file by using the XSL code generated.
class java.lang.Object class java.beans.SimpleBeanInfo (implements java.beans.BeanInfo)
class oracle.xml.differ.XMLDiffBeanInfo
class oracle.xml.differ.XMLDiff (implements oracle.xml.async.DOMBuilderErrorListener, oracle.xml.async.DOMBuilderListener, java.io.Serializable)
Class | Description |
---|---|
Defines an interface for comparing two XML documents. |
|
Extends |
Public class XMLDiff
Extends java.lang.Object
Implements DOMBuilderListener, DOMBuilderErrorListener, java.io.Serializable
Defines an interface for comparing two XML files. It enables two XML files to be compared to check for their equivalence. It provides the objects to display the differences, if any, in a graphical format. The differences can also be represented as XSL. The corresponding XSL stylesheet with the differences can be generated as a file or an XMLDocument object. The first XML file can be transformed into the second XML file by using the XSL stylesheet generated.
java.lang.Object
|
+--oracle.xml.differ.XMLDiff
public XMLDiff()
Sets the XML files which need to be compared. Both files are parsed into DOM trees for comparision. This is faster than calling setInput1() and setInput2()
public void setFiles(java.io.File file1, java.io.File file2)
File - first XML file (separate File
with comma for each increment)
File - second XML file
java.io.IOException - thrown when an I/O error occurs
XMLParseException - caused when parsing XML document
SAXException - caused when parsing XML document
java.lang.InterruptedException - if a sleeping thread is interrupted
Sets the XML documents which need to be compared.
public void setDocuments(XMLDocument doc1, XMLDocument doc2)
XMLDocument - first XML document
XMLDocument - second XML document
Sets the first XML file that needs to be compared. The input file is parsed into a DOM tree for comparision.
public void setInput1(java.io.File file1)
File - first XML file
java.io.IOException - thrown when an I/O error occurs
XMLParseException - caused when parsing XML document
SAXException - caused when parsing XML document
java.lang.InterruptedException - if a sleeping thread is interrupted
Sets the second XML file that needs to be compared. The input file is parsed into a DOM tree for comparision.
public void setInput2(java.io.File file2)
File - second XML file
java.io.IOException - thrown when an I/O error occurs
XMLParseException - caused when parsing XML document
SAXException - caused when parsing XML document
java.lang.InterruptedException - if a sleeping thread is interrupted
Sets the first XML document which need to be compared.
public void setInput1(XMLDocument doc1)
XMLDocument - first XML document
Sets the second XML document which need to be compared.
public void setInput2(XMLDocument doc2)
XML - Document second XML document
Gets the document root as an XMLDocument object of the first XML tree
public XMLDocument getDocument1()
the document root of the first XML file
public XMLDocument getDocument2()
Gets the document root as an XMLDocument object of the second XML tree
Returns:
the document root of the second XML file
Finds the differences between the two XML files or the two XMLDocument objects.
public boolean diff()
false if the XML files or docs are same, true if they are different
java.lang.NullPointerException - occurs when xml files were not parsed successfully and this function was called. Or if xml documents have not been set.
Gets the text panel as JTextPane object which visually shows the diffs in the first XML file.
public javax.swing.JTextPane getDiffPane1()
visual text panel showing diffs in first XML file
Gets the text panel as JTextPane object which visually shows the diffs in the second XML file or document
public javax.swing.JTextPane getDiffPane2()
visual text panel showing diffs in second XML file
Sets the indentation for the XSL generation. This should be called before the generateXSLFile() or generateXSLDoc(). The indentation will be applied to all attributes only. For indenting newly inserted nodes besides attributes see setNewNodeIndentIncr()
public void setIndentIncr(int spaces)
int - indentation increment in number of spaces for attributes
Sets the indentation for the XSL generation. This should be called before the generateXSLFile() or generateXSLDoc(). The indentation will be applied to all newly inserted nodes only (except attributes). For indentation attributes supported, see setIndentIncr().
public void setNewNodeIndentIncr(int spaces)
int - indentation increment in number of spaces for new nodes
Generates an XSL file of input filename which represents the differences between the 2 XML files which were set initially. If the input filename is null a default XSL file named XMLDiff.xsl will be generated. The first XML file can be transformed into the second XML file using the XSL stylesheet generated. If the XML files were the same then the XSL generated will transform the first XML file into the second XML file, where the first and second files will equivalent.
public void generateXSLFile(java.lang.String filename)
String - output XSL file name
java.io.IOException - could occur if the xsl file was not created successfully
Generates an XSL stylesheet as an XMLDocument which represents the differences between the 2 XML documents set initially. The first XML file can be transformed into the second XML file using the XSL stylesheet generated. If the XML files were the same then the XSL generated will transform the first XML file into the second XML file, where the first and second files will equivalent.
public XMLDocument generateXSLDoc()
XSL stylesheet as an XML document
java.io.IOException - could occur if the xsl file was not created successfully
java.io.FileNotFoundException - if xsl file generated could not be found
SAXException - caused when parsing xml document
XMLParseException - caused when parsing xml document
Method that performs the comparision of two (2) nodes. It is called by the differ algorithm. If needed, this function can be overwritten for customized comparisions.
protected boolean equals(Node node1, Node node2)
Node - node1 first node to compare
Node - node2 second node to compare
Method implementing the DOMBuilderErrorListener interface called only by the DOM parser when there is an error while parsing.
public void domBuilderErrorCalled(DOMBuilderErrorEvent p0)
domBuilderErrorCalled in interface DOMBuilderErrorListener
DOMBuilderErrorEvent - error object thrown by parser
Method implementing the DOMBuilderErrorListener interface called only by the DOM parser.
public void domBuilderError(DOMBuilderEvent p0)
domBuilderError in interface DOMBuilderListener
DOMBuilderEvent - parser event Parser errors handled by domBuilderErrorCalled
Method implementing DOMBuilderListener interface called only by a DOM parser thread when the parsing is done.
public void domBuilderOver(DOMBuilderEvent p0)
domBuilderOver in interface DOMBuilderListener
DOMBuilderEvent - parser event
Method implementing DOMBuilderListener interface called only by the DOM parser when the parsing starts.
public void domBuilderStarted(DOMBuilderEvent p0)
domBuilderStarted in interface DOMBuilderListener
DOMBuilderEvent - parser event
Prints the diff tree which contains the node names and values which have been identified as diffs by the algorithm. Useful for debugging.
public void printDiffTree(int tree, java.io.BufferedWriter out)
int - the tree to print, i.e. one or two
BufferedWriter - containing the printed diff tree
java.io.IOException - could occur if the xsl file was not created successfully
Assume that there are no moves to be detected by the diff algorithm. This function should be called before the diff() function. It will result in a performance gain.
public void setNoMoves()
Public class XMLDiffBeanInfo
Extends java.beans.SimpleBeanInfo
java.lang.Object | +--java.beans.SimpleBeanInfo | +--oracle.xml.differ.XMLDiffBeanInfo
public XMLDiffBeanInfo()
public java.beans.PropertyDescriptor[ ] getPropertyDescriptors()
getPropertyDescriptors in class java.beans.SimpleBeanInfo
public java.awt.Image getIcon(int iconKind)
getIcon in class java.beans.SimpleBeanInfo
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|