Program: 81280
Project: 81280
Buggy source:
/** 
 * Parses the child elements.
 * @param nsprefix namespace
 * @param ctype complex type
 * @param ctypes collection of all complex types
 * @param element parent complex type
 * @param xsdDocument handle to xsd document
 * @return list of all children of the given element node and alsoassociates with the complex type to enable traversal.
 * @throws XsdDocException 
 */
private Set<Element> parseChildElements(ComplexType ctype,org.w3c.dom.Element element,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{ctype,ctypes,element,xsdDocument});
  Set<Element> elements=new TreeSet<Element>();
  NodeList domElements=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  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);
    elem.setContainerComplexType(ctype);
    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);
    }
    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));
    elements.add(elem);
    postProcessElement(elem,obj);
    xsdDocument.addIndependentElement(elem);
  }
  NodeList attributeNodes=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  if (attributeNodes != null) {
    int count=attributeNodes.getLength();
    for (int j=0; j < count; j++) {
      org.w3c.dom.Element attrElem=(org.w3c.dom.Element)attributeNodes.item(j);
      AttributeElement attr=Context.getContext().getNewAttribute();
      String name=attrElem.getAttribute("String_Node_Str");
      if (Utils.isEmpty(name)) {
        for (int k=0; k < count; k++) {
          org.w3c.dom.Element ref=(org.w3c.dom.Element)attributeNodes.item(k);
          name=ref.getAttribute("String_Node_Str");
        }
      }
      String type=attrElem.getAttribute("String_Node_Str");
      attr.setContainerComplexType(ctype);
      String prevComment=Utils.getPreviousComment(attrElem);
      String nextComment=Utils.getNextComment(attrElem);
      if (prevComment != null || nextComment != null) {
        Comment comment=new Comment();
        comment.setNextComment(nextComment);
        comment.setPreviousComment(prevComment);
        attr.setComment(comment);
      }
      if (Utils.isEmpty(type)) {
        NodeList simpleTypes=attrElem.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
        if (simpleTypes.getLength() > 0) {
          org.w3c.dom.Element elem=(org.w3c.dom.Element)simpleTypes.item(0);
          SimpleType simpleType=populateSimpleType(xsdDocument,elem,true);
          if (Utils.isEmpty(simpleType.getName())) {
            simpleType.setName(ctype.getName() + name + "String_Node_Str");
            if (simpleType.getEnums() != null) {
              for (              EnumElement enumE : simpleType.getEnums()) {
                enumE.setType(simpleType.getName());
              }
            }
          }
          xsdDocument.addSimpleType(simpleType);
          attr.setType(simpleType.getName());
          attr.setBaseType(simpleType.getName());
        }
      }
 else {
        attr.setType(type);
      }
      attr.setName(name);
      org.w3c.dom.Element parent=(org.w3c.dom.Element)attrElem.getParentNode();
      if (parent.getTagName().endsWith("String_Node_Str")) {
        String baseType=parent.getAttribute("String_Node_Str");
        attr.setBaseType(baseType);
      }
      NamedNodeMap nameNodeMap=attrElem.getAttributes();
      int size=nameNodeMap.getLength();
      for (int k=0; k < size; k++) {
        Attr attri=(Attr)nameNodeMap.item(k);
        if (attri != null) {
          Attribute attribute=new Attribute();
          attribute.setName(attri.getName());
          attribute.setValue(attri.getValue());
          attr.getAttributes().add(attribute);
        }
      }
      attr.setAnnotationInfo(parseAnnotation(attrElem));
      postProcessAttribute(attr,attrElem);
      ctype.addSimpleAttributeContent(attr);
    }
  }
  NodeList extensibleElements=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  org.w3c.dom.Element extensionbaseElem=(org.w3c.dom.Element)extensibleElements.item(0);
  if (extensionbaseElem != null) {
    String attribute=extensionbaseElem.getAttribute("String_Node_Str");
    String parentType=null;
    String[] strs=attribute.split("String_Node_Str");
    if (strs != null && strs.length > 1)     parentType=strs[1];
 else     parentType=attribute;
    ctype.setParentType(parentType);
    if (!Utils.isEmpty(parentType)) {
      xsdDocument.addParentToComplexTypeMap(parentType,ctype.getName());
    }
  }
  logger.log(Level.FINER,"String_Node_Str",new Object[]{elements});
  return elements;
}

Fixed version (ground truth):
/** 
 * Parses the child elements.
 * @param nsprefix namespace
 * @param ctype complex type
 * @param ctypes collection of all complex types
 * @param element parent complex type
 * @param xsdDocument handle to xsd document
 * @return list of all children of the given element node and alsoassociates with the complex type to enable traversal.
 * @throws XsdDocException 
 */
private Set<Element> parseChildElements(ComplexType ctype,org.w3c.dom.Element element,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{ctype,ctypes,element,xsdDocument});
  Set<Element> elements=new TreeSet<Element>();
  NodeList domElements=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  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);
    elem.setContainerComplexType(ctype);
    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);
    }
    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));
    elements.add(elem);
    postProcessElement(elem,obj);
    xsdDocument.addIndependentElement(elem);
  }
  NodeList attributeNodes=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  if (attributeNodes != null) {
    int count=attributeNodes.getLength();
    for (int j=0; j < count; j++) {
      org.w3c.dom.Element attrElem=(org.w3c.dom.Element)attributeNodes.item(j);
      AttributeElement attr=Context.getContext().getNewAttribute();
      String name=attrElem.getAttribute("String_Node_Str");
      if (Utils.isEmpty(name)) {
        for (int k=0; k < count; k++) {
          org.w3c.dom.Element ref=(org.w3c.dom.Element)attributeNodes.item(k);
          name=ref.getAttribute("String_Node_Str");
        }
      }
      String type=attrElem.getAttribute("String_Node_Str");
      attr.setContainerComplexType(ctype);
      String prevComment=Utils.getPreviousComment(attrElem);
      String nextComment=Utils.getNextComment(attrElem);
      if (prevComment != null || nextComment != null) {
        Comment comment=new Comment();
        comment.setNextComment(nextComment);
        comment.setPreviousComment(prevComment);
        attr.setComment(comment);
      }
      if (Utils.isEmpty(type)) {
        NodeList simpleTypes=attrElem.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
        if (simpleTypes.getLength() > 0) {
          org.w3c.dom.Element elem=(org.w3c.dom.Element)simpleTypes.item(0);
          SimpleType simpleType=populateSimpleType(xsdDocument,elem,true);
          if (Utils.isEmpty(simpleType.getName())) {
            simpleType.setName(ctype.getName() + name + "String_Node_Str");
          }
          if (simpleType.getEnums() != null) {
            for (            EnumElement enumE : simpleType.getEnums()) {
              enumE.setType(simpleType.getName());
              xsdDocument.addEnum(enumE);
            }
          }
          xsdDocument.addSimpleType(simpleType);
          attr.setType(simpleType.getName());
          attr.setBaseType(simpleType.getName());
        }
      }
 else {
        attr.setType(type);
      }
      attr.setName(name);
      org.w3c.dom.Element parent=(org.w3c.dom.Element)attrElem.getParentNode();
      if (parent.getTagName().endsWith("String_Node_Str")) {
        String baseType=parent.getAttribute("String_Node_Str");
        attr.setBaseType(baseType);
      }
      NamedNodeMap nameNodeMap=attrElem.getAttributes();
      int size=nameNodeMap.getLength();
      for (int k=0; k < size; k++) {
        Attr attri=(Attr)nameNodeMap.item(k);
        if (attri != null) {
          Attribute attribute=new Attribute();
          attribute.setName(attri.getName());
          attribute.setValue(attri.getValue());
          attr.getAttributes().add(attribute);
        }
      }
      attr.setAnnotationInfo(parseAnnotation(attrElem));
      postProcessAttribute(attr,attrElem);
      ctype.addSimpleAttributeContent(attr);
    }
  }
  NodeList extensibleElements=element.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  org.w3c.dom.Element extensionbaseElem=(org.w3c.dom.Element)extensibleElements.item(0);
  if (extensionbaseElem != null) {
    String attribute=extensionbaseElem.getAttribute("String_Node_Str");
    String parentType=null;
    String[] strs=attribute.split("String_Node_Str");
    if (strs != null && strs.length > 1)     parentType=strs[1];
 else     parentType=attribute;
    ctype.setParentType(parentType);
    if (!Utils.isEmpty(parentType)) {
      xsdDocument.addParentToComplexTypeMap(parentType,ctype.getName());
    }
  }
  logger.log(Level.FINER,"String_Node_Str",new Object[]{elements});
  return elements;
}