Program: 109161
Project: 109161
Buggy source:
/** 
 * Format this XML data as a String.
 * @webref xml:method
 * @brief Formats XML data as a String
 * @param indent -1 for a single line (and no declaration), >= 0 for indents and newlines
 * @return the content
 * @see XML#toString()
 */
public String format(int indent){
  try {
    boolean useIndentAmount=false;
    TransformerFactory factory=TransformerFactory.newInstance();
    if (indent != -1) {
      try {
        factory.setAttribute("String_Node_Str",indent);
      }
 catch (      IllegalArgumentException e) {
        useIndentAmount=true;
      }
    }
    Transformer transformer=factory.newTransformer();
    if (indent == -1 || parent == null) {
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    }
 else {
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    }
    transformer.setOutputProperty(OutputKeys.METHOD,"String_Node_Str");
    if (useIndentAmount) {
      transformer.setOutputProperty("String_Node_Str",String.valueOf(indent));
    }
    transformer.setOutputProperty(OutputKeys.ENCODING,"String_Node_Str");
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    final String decl="String_Node_Str";
    StringWriter tempWriter=new StringWriter();
    StreamResult tempResult=new StreamResult(tempWriter);
    transformer.transform(new DOMSource(node),tempResult);
    String[] tempLines=PApplet.split(tempWriter.toString(),'\n');
    PApplet.println(tempLines);
    if (tempLines[0].startsWith(decl)) {
      int declEnd=tempLines[0].indexOf("String_Node_Str") + 2;
      if (tempLines[0].length() == declEnd) {
        PApplet.println("String_Node_Str");
        tempLines=PApplet.subset(tempLines,1);
      }
 else {
        PApplet.println("String_Node_Str");
        tempLines[0]=tempLines[0].substring(declEnd);
      }
    }
    String singleLine=PApplet.join(PApplet.trim(tempLines),"String_Node_Str");
    if (indent == -1) {
      return singleLine;
    }
    StringWriter stringWriter=new StringWriter();
    StreamResult xmlOutput=new StreamResult(stringWriter);
    Source source=new StreamSource(new StringReader(singleLine));
    transformer.transform(source,xmlOutput);
    return decl + "String_Node_Str" + stringWriter.toString();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Format this XML data as a String.
 * @webref xml:method
 * @brief Formats XML data as a String
 * @param indent -1 for a single line (and no declaration), >= 0 for indents and newlines
 * @return the content
 * @see XML#toString()
 */
public String format(int indent){
  try {
    boolean useIndentAmount=false;
    TransformerFactory factory=TransformerFactory.newInstance();
    if (indent != -1) {
      try {
        factory.setAttribute("String_Node_Str",indent);
      }
 catch (      IllegalArgumentException e) {
        useIndentAmount=true;
      }
    }
    Transformer transformer=factory.newTransformer();
    if (indent == -1 || parent == null) {
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    }
 else {
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
    }
    transformer.setOutputProperty(OutputKeys.METHOD,"String_Node_Str");
    if (useIndentAmount) {
      transformer.setOutputProperty("String_Node_Str",String.valueOf(indent));
    }
    transformer.setOutputProperty(OutputKeys.ENCODING,"String_Node_Str");
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    final String decl="String_Node_Str";
    final String sep=System.getProperty("String_Node_Str");
    StringWriter tempWriter=new StringWriter();
    StreamResult tempResult=new StreamResult(tempWriter);
    transformer.transform(new DOMSource(node),tempResult);
    String[] tempLines=PApplet.split(tempWriter.toString(),sep);
    if (tempLines[0].startsWith("String_Node_Str")) {
      int declEnd=tempLines[0].indexOf("String_Node_Str") + 2;
      if (tempLines[0].length() == declEnd) {
        tempLines=PApplet.subset(tempLines,1);
      }
 else {
        tempLines[0]=tempLines[0].substring(declEnd);
      }
    }
    String singleLine=PApplet.join(PApplet.trim(tempLines),"String_Node_Str");
    if (indent == -1) {
      return singleLine;
    }
    StringWriter stringWriter=new StringWriter();
    StreamResult xmlOutput=new StreamResult(stringWriter);
    Source source=new StreamSource(new StringReader(singleLine));
    transformer.transform(source,xmlOutput);
    return decl + sep + stringWriter.toString();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}