Parser p = new Parser(); facit = p.parse( merged.getCanonicalPath() ); mr1 = p.parse( "m1.xml" ); mr2 = p.parse( "m2.xml" );
XMLParser p = new XMLParser(); facit = (BaseNode) p.parse( merged.getCanonicalPath(),baseNodeFactory); mr1 = (BaseNode) p.parse( "m1.xml",baseNodeFactory ); mr2 = (BaseNode) p.parse( "m2.xml",baseNodeFactory );
  private void runCase( File dir ) {    final boolean SHOWDIFF = true;    File base = new File( dir, "b.xml");    File b1 = new File( dir, "1.xml");    File b2 = new File( dir, "2.xml");    File merged = new File( dir, "m.xml");    File notes = new File( dir,"notes" );    ElementNode docA=null, docB=null, docBase=null;    System.out.println("Running case " + dir.getName() );    if( notes.exists() ) {      try {        BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( notes ) ) );        String s="";        while((s=in.readLine())!=null)          System.out.println("NOTES: "+s);      } catch (Exception e ) {          System.out.println("NOTES: READ EXCEPTED ");      }    }    try {      Parser p = new Parser();//      System.out.println("Parsing " + base.getCanonicalPath() );      docBase = p.parse( base.getCanonicalPath() );//      System.out.println("Parsing " + base.getCanonicalPath() );      docA = p.parse( b1.getCanonicalPath() );//      System.out.println("Parsing " + base.getCanonicalPath() );      docB = p.parse( b2.getCanonicalPath() );/*      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 ) {      System.out.println("PARSE ERROR IN CASE, giving up." );      //e.printStackTrace();      return;    }    ProtoBestMatching m1 = new ProtoBestMatching( docBase, docA, "docA" );     File mf1 = new File( dir, "match1");     if( mf1.exists() ) {      System.out.println("Additional matchings from "+mf1.getName());      m1.matchFromFile(mf1);     }    ProtoBestMatching m2 = new ProtoBestMatching( docBase, docB, "docB" );     File mf2 = new File( dir, "match2");     if( mf2.exists() ) {      System.out.println("Additional matchings from "+mf2.getName());      m2.matchFromFile(mf2);     }    Merge merge1 = new Merge( new TriMatching( docA, m1, docBase, m2, docB ) );    Merge merge2 = new Merge( new TriMatching( docB, m2, docBase, m1, docA ) );    PrintWriter p1 = null, p2=null;    try {      p1 = new PrintWriter( new FileOutputStream( "m1.xml" ) );      p2 = new PrintWriter( new FileOutputStream( "m2.xml" ) );    } catch (java.io.FileNotFoundException e ) {      System.out.println("ERROR: Can't write merged files");      return;    }    try {      merge1.merge( new MergePrinter(p1) );      merge2.merge( new MergePrinter(p2) );    } catch ( org.xml.sax.SAXException e ) {      System.out.println("SAXException while merging.. and it was yoyr lousy content handler that threw it");    }    p1.close();p2.close();    System.out.print("Checking merges... " );    ElementNode facit=null,mr1=null,mr2=null;    try {      Parser p = new Parser();      facit = p.parse( merged.getCanonicalPath() );      mr1 = p.parse( "m1.xml" );      mr2 = p.parse( "m2.xml" );    } catch ( Exception e ) {      System.out.println("PARSE ERROR IN CASE when parsing merged files. Giving up." +e.getMessage() );      //e.printStackTrace();      return;    }    boolean symmetry = treesIdentical(mr1,mr2,false),            likefacit = treesIdentical(mr1,facit,SHOWDIFF);    if( !symmetry )      System.out.print("SYMMETRY failed ");    if( ((ElementNode) facit.getChild(0)).name.equalsIgnoreCase("conflict") ) {      System.out.println("Facit says this was a CONFLICT" );      return;    }    if( !likefacit )      System.out.print("FACIT failed " + ( symmetry || (!symmetry && !treesIdentical(facit,mr2,false)) ?        "(on both)" : "(on one only)" ) );    if( likefacit && symmetry )      System.out.println("Ok ");    else {      PrintWriter pw = new PrintWriter( System.out );      pw.println( !symmetry ? "\nMerge 1: " : "\nMerge" );      try {        merge1.merge( new MergePrinter(pw) );        if( !symmetry ) {          pw.println( "Merge 2:"  );          merge2.merge( new MergePrinter(pw) );        }      } catch ( Exception e ) {        System.out.println("PARSE ERROR..." );      }      pw.flush();    }    return;  }