Program: 147852
Project: 147852
Buggy source:
private void importSchema(InputSource source,String uri) throws Exception {
  String ns="String_Node_Str";
  DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
  documentBuilderFactory.setNamespaceAware(true);
  documentBuilderFactory.setValidating(false);
  DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
  Document document=documentBuilder.parse(source);
  ns=document.getDocumentElement().getAttribute("String_Node_Str");
  if (xsdSchema == null)   xsdSchema=getXSDSchema(Util.nodeToString(document));
 else {
    WSDataModel wsObject=(WSDataModel)(xobject.getWsObject());
    xsdSchema=Util.createXsdSchema(wsObject.getXsdSchema(),xobject);
  }
  boolean exist=false;
  for (int i=0; i < xsdSchema.getContents().size(); i++) {
    XSDSchemaContent xsdComp=xsdSchema.getContents().get(i);
    if (ns != null && !ns.equals("String_Node_Str")) {
      if (xsdComp instanceof XSDImport && ((XSDImport)xsdComp).getNamespace().equals(ns)) {
        for (        Map.Entry entry : xsdSchema.getQNamePrefixToNamespaceMap().entrySet()) {
          if (entry.getValue().equals(((XSDImport)xsdComp).getNamespace())) {
            exist=true;
            break;
          }
        }
        break;
      }
    }
 else {
      if (xsdComp instanceof XSDInclude) {
        String xsdLocation=((XSDInclude)xsdComp).getSchemaLocation();
        if (xsdLocation.equals(uri)) {
          exist=true;
          break;
        }
      }
    }
  }
  if (!exist) {
    if (ns != null && !ns.equals("String_Node_Str")) {
      int last=ns.lastIndexOf("String_Node_Str");
      xsdSchema.getQNamePrefixToNamespaceMap().put(ns.substring(last + 1).replaceAll("String_Node_Str","String_Node_Str"),ns);
      XSDImport xsdImport=XSDFactory.eINSTANCE.createXSDImport();
      xsdImport.setNamespace(ns);
      xsdImport.setSchemaLocation(uri);
      xsdSchema.getContents().add(0,xsdImport);
    }
 else {
      XSDInclude xsdInclude=XSDFactory.eINSTANCE.createXSDInclude();
      xsdInclude.setSchemaLocation(uri);
      xsdSchema.getContents().add(0,xsdInclude);
    }
    String xsd=Util.nodeToString(xsdSchema.getDocument());
    setXsdSchema(xsdSchema);
    WSDataModel wsObject=(WSDataModel)(xobject.getWsObject());
    wsObject.setXsdSchema(xsd);
  }
}

Fixed version (ground truth):
protected void importSchema(InputSource source,String uri) throws Exception {
  String ns="String_Node_Str";
  DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
  documentBuilderFactory.setNamespaceAware(true);
  documentBuilderFactory.setValidating(false);
  DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
  Document document=documentBuilder.parse(source);
  ns=document.getDocumentElement().getAttribute("String_Node_Str");
  if (xsdSchema == null)   xsdSchema=getXSDSchema(Util.nodeToString(document));
 else {
    WSDataModel wsObject=(WSDataModel)(xobject.getWsObject());
    xsdSchema=Util.createXsdSchema(wsObject.getXsdSchema(),xobject);
  }
  boolean exist=false;
  for (int i=0; i < xsdSchema.getContents().size(); i++) {
    XSDSchemaContent xsdComp=xsdSchema.getContents().get(i);
    if (ns != null && !ns.equals("String_Node_Str")) {
      if (xsdComp instanceof XSDImport && ((XSDImport)xsdComp).getNamespace().equals(ns)) {
        for (        Map.Entry entry : xsdSchema.getQNamePrefixToNamespaceMap().entrySet()) {
          if (entry.getValue().equals(((XSDImport)xsdComp).getNamespace())) {
            exist=true;
            break;
          }
        }
        break;
      }
    }
 else {
      if (xsdComp instanceof XSDInclude) {
        String xsdLocation=((XSDInclude)xsdComp).getSchemaLocation();
        if (xsdLocation.equals(uri)) {
          exist=true;
          break;
        }
      }
    }
  }
  if (!exist) {
    if (ns != null && !ns.equals("String_Node_Str")) {
      int last=ns.lastIndexOf("String_Node_Str");
      xsdSchema.getQNamePrefixToNamespaceMap().put(ns.substring(last + 1).replaceAll("String_Node_Str","String_Node_Str"),ns);
      XSDImport xsdImport=XSDFactory.eINSTANCE.createXSDImport();
      xsdImport.setNamespace(ns);
      xsdImport.setSchemaLocation(uri);
      xsdSchema.getContents().add(0,xsdImport);
    }
 else {
      XSDInclude xsdInclude=XSDFactory.eINSTANCE.createXSDInclude();
      xsdInclude.setSchemaLocation(uri);
      xsdSchema.getContents().add(0,xsdInclude);
    }
    String xsd=Util.nodeToString(xsdSchema.getDocument());
    setXsdSchema(xsdSchema);
    WSDataModel wsObject=(WSDataModel)(xobject.getWsObject());
    wsObject.setXsdSchema(xsd);
  }
}