This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 82832 - Request prettyPrint and xmlDiff utility function
Summary: Request prettyPrint and xmlDiff utility function
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: XDM (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Ayub Khan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-16 19:42 UTC by wchui
Modified: 2007-04-11 00:08 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wchui 2006-08-16 19:42:30 UTC
In enterprise/jbiTester subcomponent, there is a requirement to use XDM for
pretty print and diff of XML. I set this priority to P2 as the dependent
jbiTester issue needs to be resolved for FCS. 

Discussed with Ayub through email and then create this issue. Below are the
discussion of items.

 1. public static String prettyPrintXML(String doc, String indentation){ }

 2.
 /*
 type is the comparison type - currently only equal, identical. */ 
 public static List<XMLUtil.Difference> compareXML(String firstDoc,  String
secondDoc, type) { };

 3. create XMLUtil classese that are used in showDiff() sample code that 
 support for locating the difference.

 public void showDiff(javax.swing.Document doc1, javax.swing.Document
 doc2) { //illustrating how to find xml difference and display in ui
    String xmlstring1 = doc1.getText(0, doc1.getLength());
    String xmlstring2 = doc2.getText(0, doc1.getLength());
    XMLUtil.DiffInfo diffInfo = XMLUtil.findDiff(xmlstring1, 
 xmlstring2); //diffInfo is an object that holds onto the internal 
 representation.
    List<XMLUtil.Difference> diffs = diffInfo.getDifferences(); 
 //returns the difference
    for(XMLUtil.Difference diff: diffs) {
       XMLUtil.OldNodeInfo oldInfo = diff.getOldNodeInfo();
       XMLUtil.NewNodeInfo oldInfo = diff.getNewNodeInfo();
       if(oldInfo  != null ) {
         XMLUtil.Position p1 = diffInfo.findPosition(oldInfo.getNode());
         //AttributeSet could indicate a different color for Add, 
 Delete, Change
         ((StyledDocument)doc1).setCharacterAttributes(p1.getBegin, 
 p1.getEnd()-p1.getBegin, AttributeSet s, true);             }
       if(oldInfo  != null ) {
         XMLUtil.Position p1 = diffInfo.findPosition(oldInfo.getNode());
         //AttributeSet could indicate a different color for Add, 
 Delete, Change
         ((StyledDocument)doc1).setCharacterAttributes(p1.getBegin, 
 p1.getEnd()-p1.getBegin, AttributeSet s, true);             }
    }
 }
Comment 1 Ayub Khan 2006-09-11 18:11:42 UTC
Implemented
XDMUtil.prettyPrintXML(...)
XDMUtil.compareXML(...)

See the testcases XDMUtilTest.java for usages.

XDMUtil.showDiff(...) - cannot be implmenetd inside of XDM, since XDM is a
model, do not have UI infrastructure. I think this method should be some UI
related module. I think this is not for NB55 FCS.

New files added:

/cvs/xml/xdm/src/org/netbeans/modules/xml/xdm/diff/Attic/XDMUtil.java
new revision: 1.1.2.1; previous revision: 1.1

/cvs/xml/xdm/test/unit/src/org/netbeans/modules/xml/xdm/diff/Attic/XDMUtilTest.java
new revision: 1.1.2.1; previous revision: 1.1
Comment 2 tonybeckham 2007-04-11 00:08:26 UTC
fix VERIFIED in NetBeans IDE Dev (Build 200704091800)