Program: 163731
Project: 163731
Buggy source:
/** 
 * Writes an XML element.
 * @param xml the non-null XML element to write.
 * @param prettyPrint if spaces need to be inserted to make the output morereadable
 * @param initialIndent how many spaces to indent the first element.
 */
public void write(XMLElement xml,boolean prettyPrint,int initialIndent,int eachIndent,boolean collapseEmptyElements) throws IOException {
  if (prettyPrint) {
    for (int i=0; i < initialIndent; i++) {
      this.writer.print(' ');
    }
  }
  if (xml.getLocalName() == null) {
    if (xml.getContent() != null) {
      if (prettyPrint) {
        this.writeEncoded(xml.getContent().trim());
        writer.println();
      }
 else {
        this.writeEncoded(xml.getContent());
      }
    }
  }
 else {
    this.writer.print('<');
    this.writer.print(xml.getName());
    for (    String key : xml.listAttributes()) {
      String value=xml.getAttribute(key,null);
      this.writer.print("String_Node_Str" + key + "String_Node_Str");
      this.writeEncoded(value);
      this.writer.print('"');
    }
    if ((xml.getContent() != null) && (xml.getContent().length() > 0)) {
      writer.print('>');
      this.writeEncoded(xml.getContent());
      writer.print("String_Node_Str" + xml.getName() + '>');
      if (prettyPrint) {
        writer.println();
      }
    }
 else     if (xml.hasChildren() || (!collapseEmptyElements)) {
      writer.print('>');
      if (prettyPrint) {
        writer.println();
      }
      int count=xml.getChildCount();
      for (int i=0; i < count; i++) {
        XMLElement child=xml.getChild(i);
        this.write(child,prettyPrint,initialIndent + eachIndent,eachIndent,collapseEmptyElements);
      }
      if (prettyPrint) {
        for (int i=0; i < initialIndent; i++) {
          this.writer.print(' ');
        }
      }
      this.writer.print("String_Node_Str" + xml.getName() + "String_Node_Str");
      if (prettyPrint) {
        writer.println();
      }
    }
 else {
      this.writer.print("String_Node_Str");
      if (prettyPrint) {
        writer.println();
      }
    }
  }
  this.writer.flush();
}

Fixed version (ground truth):
/** 
 * Writes an XML element.
 * @param xml the non-null XML element to write.
 * @param prettyPrint if spaces need to be inserted to make the output morereadable
 * @param initialIndent how many spaces to indent the first element.
 */
public void write(XMLElement xml,boolean prettyPrint,int initialIndent,int eachIndent,boolean collapseEmptyElements) throws IOException {
  if (prettyPrint) {
    for (int i=0; i < initialIndent; i++) {
      this.writer.print(' ');
    }
  }
  if (xml.getLocalName() == null) {
    if (xml.getContent() != null) {
      if (prettyPrint) {
        this.writeEncoded(xml.getContent().trim());
        writer.println();
      }
 else {
        this.writeEncoded(xml.getContent());
      }
    }
  }
 else {
    this.writer.print('<');
    this.writer.print(xml.getName());
    for (    String key : xml.listAttributes()) {
      String value=xml.getString(key,null);
      this.writer.print("String_Node_Str" + key + "String_Node_Str");
      this.writeEncoded(value);
      this.writer.print('"');
    }
    if ((xml.getContent() != null) && (xml.getContent().length() > 0)) {
      writer.print('>');
      this.writeEncoded(xml.getContent());
      writer.print("String_Node_Str" + xml.getName() + '>');
      if (prettyPrint) {
        writer.println();
      }
    }
 else     if (xml.hasChildren() || (!collapseEmptyElements)) {
      writer.print('>');
      if (prettyPrint) {
        writer.println();
      }
      int count=xml.getChildCount();
      for (int i=0; i < count; i++) {
        XMLElement child=xml.getChild(i);
        this.write(child,prettyPrint,initialIndent + eachIndent,eachIndent,collapseEmptyElements);
      }
      if (prettyPrint) {
        for (int i=0; i < initialIndent; i++) {
          this.writer.print(' ');
        }
      }
      this.writer.print("String_Node_Str" + xml.getName() + "String_Node_Str");
      if (prettyPrint) {
        writer.println();
      }
    }
 else {
      this.writer.print("String_Node_Str");
      if (prettyPrint) {
        writer.println();
      }
    }
  }
  this.writer.flush();
}