docMerged = clonedAndMatchedTree( docBase, true, true, null );
docMerged = clonedAndMatchedTree( docBase, true, true, false, null );
  public void editGen( String inFile, String mergeFile, String[] outfiles ) {    // Parse infile   MarkableBaseNode docBase=null;   BranchNode docMerged=null;   System.err.println("Parsing "+inFile+"...");   try {     XMLParser p = new XMLParser();     docBase = (MarkableBaseNode) p.parse( inFile,baseNodeFactory);     countSubtreeSizes(docBase); // We need subtree counts to alloc a random node   } catch ( Exception e ) {     System.err.println("XML Parse error in " + inFile +                        ". Detailed exception info is:" );     System.err.println( e.toString() );     e.printStackTrace();     return;   }   // Make merge clone   // total merge is left tree, current working tree is right   docMerged = clonedAndMatchedTree( docBase, true, true, null );   EditLog mergeLog = new EditLog();   // Make variants   for( int iFile = 0; iFile < outfiles.length; iFile++ ) {     System.err.println("Making "+outfiles[iFile]+"...");     EditLog branchLog = new EditLog();     BranchNode outRoot = clonedAndMatchedTree( docBase, false, true, null );     ((MarkableBaseNode) docBase).mark(MarkableBaseNode.MARK_STRUCTURE | MarkableBaseNode.MARK_CONTENT);     ((MarkableBaseNode) docBase.getChild(0)).mark(MarkableBaseNode.MARK_STRUCTURE); // Never edit root elem     int edits = editCount == -1 ?                 (int) (((MarkableBaseNode) docBase).getSubteeSize()*                 (probability/outfiles.length)) :                 editCount;     transform( edits, (MarkableBaseNode) docBase.getChild(0),                (MarkableBaseNode) docBase.getChild(0), mergeLog, branchLog);     try {       printTree( outRoot, new XMLPrinter( new java.io.FileOutputStream( outfiles[iFile] )));     } catch (java.io.IOException x ) {       System.err.println("Unable to write outfile "+outfiles[iFile] );     }     if( editLogPrefix != null ) {       String editLogFile = editLogPrefix+outfiles[iFile];       try {         branchLog.writeEdits(new XMLPrinter( new java.io.FileOutputStream( editLogFile )));       } catch (Exception x ) {         System.err.println("Unable to write edit log "+editLogFile );       }     }   }   // Write merge facit   try {     printTree( docMerged, new XMLPrinter( new java.io.FileOutputStream( mergeFile )));   } catch (java.io.IOException x ) {     System.err.println("Unable to write outfile "+mergeFile );   }   // Write combined log   if( editLogPrefix != null ) {     String mergeLogFile = editLogPrefix+mergeFile;     try {       mergeLog.writeEdits(new XMLPrinter( new java.io.FileOutputStream( mergeLogFile )));     } catch (Exception x ) {       System.err.println("Unable to write edit log "+mergeLogFile );     }   }   if( printStats ) {     System.err.println("Base tree nodes: "+((MarkableBaseNode) docBase.getChild(0)).getSubteeSize());     System.err.println("        Inserts: "+insCount);     System.err.println("        Deletes: "+delCount);     System.err.println("        Updates: "+updCount);     System.err.println("          Moves: "+moveCount);     System.err.println("         Copies: "+copyCount);     System.err.println("    Total edits: "+(insCount+delCount+updCount+moveCount+copyCount));   }  }