Program: 44036
Project: 44036
Buggy source:
/** 
 * Parses the all elements.
 * @param tagName the tag name
 * @param srcDoc the src doc
 * @param xsdDocument parses "element" nodes from the document and constructs its POJO representation. sticks the annotation associated with the element.
 * @throws ParserException 
 */
private void parseAllElements(String tagName,Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{tagName,srcDoc,xsdDocument});
  List<Element> elements=new ArrayList<Element>();
  NodeList domElements=srcDoc.getElementsByTagName(tagName);
  int noOfDomElements=domElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)domElements.item(i);
    String name=obj.getAttribute("String_Node_Str");
    String type=obj.getAttribute("String_Node_Str");
    String[] typeParts=type.split("String_Node_Str");
    if (typeParts != null && typeParts.length > 1)     type=typeParts[1];
    Element elem=Context.getContext().getNewElement();
    elem.setName(name);
    elem.setType(type);
    String prevComment=Utils.getPreviousComment(obj);
    String nextComment=Utils.getNextComment(obj);
    if (prevComment != null || nextComment != null) {
      Comment comment=new Comment();
      comment.setNextComment(nextComment);
      comment.setPreviousComment(prevComment);
      elem.setComment(comment);
    }
    List<Element> instances=(List<Element>)typeElementsMap.get(type);
    if (instances == null) {
      instances=new ArrayList<Element>();
      instances.add(elem);
      typeElementsMap.put(type,instances);
    }
 else {
      instances.add(elem);
      typeElementsMap.put(type,instances);
    }
    NamedNodeMap nameNodeMap=obj.getAttributes();
    int size=nameNodeMap.getLength();
    for (int j=0; j < size; j++) {
      Attr attr=(Attr)nameNodeMap.item(j);
      if (attr != null) {
        Attribute attribute=new Attribute();
        attribute.setName(attr.getName());
        attribute.setValue(attr.getValue());
        elem.getAttributes().add(attribute);
      }
    }
    elem.setAnnotationInfo(parseAnnotation(obj));
    postProcessElement(elem,obj);
    elements.add(elem);
    xsdDocument.addIndependentElement(elem);
    logger.log(Level.FINER,"String_Node_Str",xsdDocument);
  }
}

Fixed version (ground truth):
/** 
 * Parses the all elements.
 * @param tagName the tag name
 * @param srcDoc the src doc
 * @param xsdDocument parses "element" nodes from the document and constructs its POJO representation. sticks the annotation associated with the element.
 * @throws ParserException 
 */
private void parseAllElements(String tagName,Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{tagName,srcDoc,xsdDocument});
  List<Element> elements=new ArrayList<Element>();
  NodeList domElements=srcDoc.getElementsByTagName(tagName);
  int noOfDomElements=domElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)domElements.item(i);
    String name=obj.getAttribute("String_Node_Str");
    Element elem=Context.getContext().getNewElement();
    elem.setName(name);
    String type=obj.getAttribute("String_Node_Str");
    if (!Utils.isEmpty(type)) {
      String[] typeParts=type.split("String_Node_Str");
      if (typeParts != null && typeParts.length > 1) {
        type=typeParts[1];
      }
    }
 else {
      NodeList nodes=obj.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
      if (nodes != null && nodes.getLength() > 0) {
        org.w3c.dom.Element node=(org.w3c.dom.Element)nodes.item(0);
        ComplexType cType=processComplexType(xsdDocument,node);
        if (Utils.isEmpty(cType.getName())) {
          cType.setName(name + "String_Node_Str");
          List<Element> instances=(List<Element>)typeElementsMap.get(name);
          if (instances != null) {
            cType.setInstanceElements(instances);
          }
 else {
            instances=new ArrayList<Element>();
            instances.add(elem);
            cType.setInstanceElements(instances);
          }
        }
        type=cType.getName();
        xsdDocument.addComplexType(cType);
      }
    }
    elem.setType(type);
    String prevComment=Utils.getPreviousComment(obj);
    String nextComment=Utils.getNextComment(obj);
    if (prevComment != null || nextComment != null) {
      Comment comment=new Comment();
      comment.setNextComment(nextComment);
      comment.setPreviousComment(prevComment);
      elem.setComment(comment);
    }
    List<Element> instances=(List<Element>)typeElementsMap.get(type);
    if (instances == null) {
      instances=new ArrayList<Element>();
      instances.add(elem);
      typeElementsMap.put(type,instances);
    }
 else {
      instances.add(elem);
      typeElementsMap.put(type,instances);
    }
    NamedNodeMap nameNodeMap=obj.getAttributes();
    int size=nameNodeMap.getLength();
    for (int j=0; j < size; j++) {
      Attr attr=(Attr)nameNodeMap.item(j);
      if (attr != null) {
        Attribute attribute=new Attribute();
        attribute.setName(attr.getName());
        attribute.setValue(attr.getValue());
        elem.getAttributes().add(attribute);
      }
    }
    elem.setAnnotationInfo(parseAnnotation(obj));
    postProcessElement(elem,obj);
    elements.add(elem);
    xsdDocument.addIndependentElement(elem);
    logger.log(Level.FINER,"String_Node_Str",xsdDocument);
  }
}