for (int ic = 0; ic < stopNode.getChildCount(); ic++) { boolean lastStopNode = ic == stopNode.getChildCount() - 1; BranchNode child = stopNode.getChild(ic); if (child.hasBaseMatch()) { Vector childStopNodes = new Vector(); m.getAreaStopNodes(childStopNodes, child); int src = getDiffId(child.getBaseMatch()); if (childStopNodes.size() == 0 && !lastStopNode) { if (s.isEmpty()) { s.init(src, dst); continue; } else if (s.appends(src, dst)) { s.append(); continue; } }  if (!s.appends(src, dst)) {   if (!s.isEmpty()) { openCopy(s.src, s.dst, s.run, ch); closeCopy(ch); } if (childStopNodes.size() > 0 || lastStopNode) { openCopy(src, dst, 1, ch); copy(child.getBaseMatch(), child, ch, childStopNodes); closeCopy(ch); s.setEmpty(); } else s.init(src, dst); } else { s.append(); openCopy(s.src, s.dst, s.run, ch); copy(child.getBaseMatch(), child, ch, childStopNodes); closeCopy(ch); s.setEmpty(); }  } else { if (!s.isEmpty()) { openCopy(s.src, s.dst, s.run, ch); closeCopy(ch); s.setEmpty(); }  AttributesImpl copyAtts = new AttributesImpl(); copyAtts.addAttribute("", "", "dst", "CDATA", String.valueOf(dst));  if (ic == 0 || stopNode.getChild(ic - 1).hasBaseMatch()) ch.startElement("", "", DIFF_NS + "insert", copyAtts); insert(child, ch); if (lastStopNode || stopNode.getChild(ic + 1).hasBaseMatch()) ch.endElement("", "", DIFF_NS + "insert"); } }
emitChildList(ch, s, stopNode, dst, false);
  protected void copy(BaseNode b, BranchNode branch, ContentHandler ch,                      Vector stopNodes) throws      SAXException {    // Find stopnodes    Sequence s = new Sequence();    for (Iterator i = stopNodes.iterator(); i.hasNext(); ) {      BranchNode stopNode = (BranchNode) i.next();      int dst = getDiffId(stopNode.getBaseMatch());      // BUGFIX 030115      if (stopNode.getChildCount() == 0) {        AttributesImpl copyAtts = new AttributesImpl();        copyAtts.addAttribute("", "", "dst", "CDATA", String.valueOf(dst));        ch.startElement("", "", DIFF_NS + "insert", copyAtts);        ch.endElement("", "", DIFF_NS + "insert");      }      // ENDBUGFIX      for (int ic = 0; ic < stopNode.getChildCount(); ic++) {        boolean lastStopNode = ic == stopNode.getChildCount() - 1;        BranchNode child = stopNode.getChild(ic);        if (child.hasBaseMatch()) {          Vector childStopNodes = new Vector();          m.getAreaStopNodes(childStopNodes, child);          int src = getDiffId(child.getBaseMatch());          if (childStopNodes.size() == 0 && !lastStopNode) {            if (s.isEmpty()) {              s.init(src, dst);              continue;            }            else if (s.appends(src, dst)) {              s.append();              continue;            }          }          // Did not append to sequence (or @ last stopnode) => emit sequence          if (!s.appends(src, dst)) {            // Current does not append to prev seq -> output prev seq + new            // in separate tags            if (!s.isEmpty()) {              openCopy(s.src, s.dst, s.run, ch);              closeCopy(ch);            }            if (childStopNodes.size() > 0 || lastStopNode) {              openCopy(src, dst, 1, ch);              copy(child.getBaseMatch(), child, ch, childStopNodes);              closeCopy(ch);              s.setEmpty(); // Reset sequence            }            else              s.init(src, dst);          }          else { // appends to open sequence (other reason for seq. break)            s.append();            openCopy(s.src, s.dst, s.run, ch);            copy(child.getBaseMatch(), child, ch, childStopNodes);            closeCopy(ch);            s.setEmpty(); // Reset sequence          }        } // endif has base match        else {          if (!s.isEmpty()) {            openCopy(s.src, s.dst, s.run, ch);            closeCopy(ch);            s.setEmpty();          }          // Insert tree...          AttributesImpl copyAtts = new AttributesImpl();          copyAtts.addAttribute("", "", "dst", "CDATA", String.valueOf(dst));          // SHORTINS = Concatenate several <ins> tags to a single one          if (ic == 0 || stopNode.getChild(ic - 1).hasBaseMatch()) // SHORTINS            ch.startElement("", "", DIFF_NS + "insert", copyAtts);          insert(child, ch);          if (lastStopNode || stopNode.getChild(ic + 1).hasBaseMatch()) // SHORTINS            ch.endElement("", "", DIFF_NS + "insert");        }      } // endfor children    }  }