Program: 122081
Project: 122081
Buggy source:
private void prepareEmfTreeFromXml(XmlFileConnection connection){
  if (!connection.isInputModel()) {
    String file=connection.getXmlFilePath();
    List<FOXTreeNode> list=new ArrayList<FOXTreeNode>();
    String rootXpath=null;
    if (!connection.getRoot().isEmpty()) {
      rootXpath=connection.getRoot().get(0).getXMLPath();
    }
 else     if (!connection.getLoop().isEmpty()) {
      rootXpath=connection.getLoop().get(0).getXMLPath();
    }
    if (rootXpath == null) {
      return;
    }
    File xmlFile=new File(file);
    if (xmlFile.exists() && !file.endsWith("String_Node_Str")) {
      list=TreeUtil.getFoxTreeNodesForXmlMap(xmlFile.getAbsolutePath(),rootXpath);
    }
 else     if (connection.getFileContent() != null && connection.getFileContent().length > 0) {
      String xsdFile=initFileContent(connection);
      if (xsdFile != null && new File(xsdFile).exists()) {
        list=TreeUtil.getFoxTreeNodesForXmlMap(xsdFile,rootXpath);
      }
    }
    root=connection.getRoot();
    loop=connection.getLoop();
    group=connection.getGroup();
    groupElements=new ArrayList<TreeNode>();
    prepareModelFromOutput(list,schemaNode);
    if (loopNode != null) {
      fillGroup(loopNode,groupElements);
    }
 else {
      if (!schemaNode.getChildren().isEmpty()) {
        schemaNode.getChildren().get(0).setLoop(true);
      }
    }
  }
 else {
    List<SchemaTarget> schemaTargets=null;
    if (!connection.getSchema().isEmpty() && connection.getSchema().get(0) instanceof XmlXPathLoopDescriptorImpl) {
      absoluteXPathQuery=((XmlXPathLoopDescriptorImpl)connection.getSchema().get(0)).getAbsoluteXPathQuery();
      schemaTargets=((XmlXPathLoopDescriptorImpl)connection.getSchema().get(0)).getSchemaTargets();
    }
    if (schemaTargets == null || schemaTargets.isEmpty()) {
      return;
    }
    this.schemaTargets=schemaTargets;
    String file=connection.getXmlFilePath();
    List<FOXTreeNode> list=new ArrayList<FOXTreeNode>();
    File xmlFile=new File(file);
    if (xmlFile.exists()) {
      list=TreeUtil.getFoxTreeNodesForXmlMap(xmlFile.getAbsolutePath(),absoluteXPathQuery);
    }
 else     if (connection.getFileContent() != null && connection.getFileContent().length > 0) {
      String xsdFile=initFileContent(connection);
      if (xsdFile != null && new File(xsdFile).exists()) {
        list=TreeUtil.getFoxTreeNodesForXmlMap(xsdFile,absoluteXPathQuery);
      }
    }
    prepareEmfTree(list,schemaNode);
  }
}

Fixed version (ground truth):
private void prepareEmfTreeFromXml(XmlFileConnection connection) throws Exception {
  if (!connection.isInputModel()) {
    String file=connection.getXmlFilePath();
    List<FOXTreeNode> list=new ArrayList<FOXTreeNode>();
    String rootXpath=null;
    if (!connection.getRoot().isEmpty()) {
      rootXpath=connection.getRoot().get(0).getXMLPath();
    }
 else     if (!connection.getLoop().isEmpty()) {
      rootXpath=connection.getLoop().get(0).getXMLPath();
    }
    if (rootXpath == null) {
      return;
    }
    File xmlFile=new File(file);
    if (xmlFile.exists() && !file.endsWith("String_Node_Str")) {
      list=TreeUtil.getFoxTreeNodesForXmlMap(xmlFile.getAbsolutePath(),rootXpath);
    }
 else     if (connection.getFileContent() != null && connection.getFileContent().length > 0) {
      String xsdFile=initFileContent(connection);
      if (xsdFile != null && new File(xsdFile).exists()) {
        list=TreeUtil.getFoxTreeNodesForXmlMap(xsdFile,rootXpath);
      }
    }
 else {
      throw new FileNotFoundException();
    }
    schemaNode.getChildren().clear();
    root=connection.getRoot();
    loop=connection.getLoop();
    group=connection.getGroup();
    groupElements=new ArrayList<TreeNode>();
    prepareModelFromOutput(list,schemaNode);
    if (loopNode != null) {
      fillGroup(loopNode,groupElements);
    }
 else {
      if (!schemaNode.getChildren().isEmpty()) {
        schemaNode.getChildren().get(0).setLoop(true);
      }
    }
  }
 else {
    List<SchemaTarget> schemaTargets=null;
    if (!connection.getSchema().isEmpty() && connection.getSchema().get(0) instanceof XmlXPathLoopDescriptorImpl) {
      absoluteXPathQuery=((XmlXPathLoopDescriptorImpl)connection.getSchema().get(0)).getAbsoluteXPathQuery();
      schemaTargets=((XmlXPathLoopDescriptorImpl)connection.getSchema().get(0)).getSchemaTargets();
    }
    if (schemaTargets == null || schemaTargets.isEmpty()) {
      return;
    }
    this.schemaTargets=schemaTargets;
    String file=connection.getXmlFilePath();
    List<FOXTreeNode> list=new ArrayList<FOXTreeNode>();
    File xmlFile=new File(file);
    if (xmlFile.exists()) {
      list=TreeUtil.getFoxTreeNodesForXmlMap(xmlFile.getAbsolutePath(),absoluteXPathQuery);
    }
 else     if (connection.getFileContent() != null && connection.getFileContent().length > 0) {
      String xsdFile=initFileContent(connection);
      if (xsdFile != null && new File(xsdFile).exists()) {
        list=TreeUtil.getFoxTreeNodesForXmlMap(xsdFile,absoluteXPathQuery);
      }
    }
    schemaNode.getChildren().clear();
    prepareEmfTree(list,schemaNode);
  }
}