try { merge2.merge( new MergePrinter(pw) ); } catch ( org.xml.sax.SAXException e ) { System.out.println("SAXException while merging.. and it was yoyr lousy content handler that threw it"); } pw.flush();
  public void run( String[] args ) {//    TreeDM handler = new TreeDM();    // Parse each file provided on the   // command line.   ElementNode docA=null, docB=null, docBase=null;   if( args.length < 3 ) {      System.out.println("Usage: TreeDM base.xml base_v1.xml base_v2.xml");      System.exit(0);   }   try {      Parser p = new Parser();      System.out.println("Parsing " + args [0]+"\\b.xml");      docBase = p.parse(args[0]+PSEP+"b.xml");      System.out.println("Parsing " + args [0]+"\\1.xml");      docA = p.parse(args[0]+PSEP+"1.xml");      System.out.println("Parsing " + args [0]+"\\2.xml");      docB = p.parse(args[0]+PSEP+"2.xml");      System.out.println("OK.");   } catch ( Exception e ) {    e.printStackTrace();    System.exit(0);   }//   System.exit(0);   ProtoBestMatching m1 = new ProtoBestMatching( docBase, docA, "docA" );   ProtoBestMatching m2 = new ProtoBestMatching( docBase, docB, "docB" );  //m1.merge2( docA, docB, m2 );   System.out.println("Should look like this:");   Merge merge = new Merge( new TriMatching( docA, m1, docBase, m2, docB ) );   java.io.ByteArrayOutputStream result = new java.io.ByteArrayOutputStream();   java.io.PrintWriter pw = new java.io.PrintWriter( result );    try {   merge.merge( new MergePrinter(pw) );    } catch ( org.xml.sax.SAXException e ) {     System.out.println("SAXException while merging.. and it was yoyr lousy content handler that threw it");    }  pw.flush();  try {result.close(); } catch (Exception e ) {}  System.out.println("Merged XML:");  System.out.print(result.toString());    /*   MapNode merged = 1==0 ? m1.merge(m2) : m1.mapRoot;   System.out.println("SHowing tree(s)" );   java.awt.Frame treeView = new TreeView( docB, docBase, m2, 1==0 ? null : m2.mapRoot );   treeView.setVisible(true);   /*   treeView = new TreeView( docB );   treeView.setVisible(true);*   System.out.println("Merged XML is" );   java.io.PrintWriter pw = new java.io.PrintWriter( System.out );   m1.printXML( pw, merged, 0 );  pw.flush();  try {    pw = new java.io.PrintWriter( new java.io.FileOutputStream("merged.xml"));     m1.printXML( pw, merged, 0 );    pw.close();  } catch (java.io.FileNotFoundException e ) {    e.printStackTrace();  }*/  }