Program: 78404
Project: 78404
Buggy source:
/** 
 * Return the root node of a schema tree.
 * @param fileName
 * @return
 * @throws OdaException
 * @throws MalformedURLException 
 * @throws URISyntaxException 
 */
public static ATreeNode getSchemaTree(String fileName,boolean incAttr) throws OdaException, MalformedURLException, URISyntaxException {
  includeAttribute=incAttr;
  DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  factory.setNamespaceAware(true);
  URI uri=null;
  File f=new File(fileName);
  uri=f.toURI();
  if (uri == null) {
    uri=new URI(fileName);
  }
  XSLoader xsLoader=new XMLSchemaLoader();
  XSModel xsModel=xsLoader.loadURI(uri.toString());
  ATreeNode complexTypesRoot=populateComplexTypeTree(xsModel);
  XSNamedMap map=xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
  ATreeNode root=new ATreeNode();
  root.setValue("String_Node_Str");
  for (int i=0; i < map.getLength(); i++) {
    ATreeNode node=new ATreeNode();
    XSElementDecl element=(XSElementDecl)map.item(i);
    node.setValue(element.getName());
    node.setType(ATreeNode.ELEMENT_TYPE);
    node.setDataType(element.getName());
    if (element.getTypeDefinition() instanceof XSComplexTypeDecl) {
      XSComplexTypeDecl complexType=(XSComplexTypeDecl)element.getTypeDefinition();
      if (complexType.getName() != null) {
        node.setDataType(complexType.getName());
        node.addChild(findComplexElement(complexTypesRoot,complexType.getName()).getChildren());
      }
 else {
        addParticleAndAttributeInfo(node,complexType,complexTypesRoot);
      }
    }
    root.addChild(node);
  }
  populateRoot(root);
  return root;
}

Fixed version (ground truth):
/** 
 * Return the root node of a schema tree.
 * @param fileName
 * @return
 * @throws OdaException
 * @throws MalformedURLException 
 * @throws URISyntaxException 
 */
public static ATreeNode getSchemaTree(String fileName,boolean incAttr) throws OdaException, MalformedURLException, URISyntaxException {
  includeAttribute=incAttr;
  DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  factory.setNamespaceAware(true);
  URI uri=null;
  File f=new File(fileName);
  uri=f.toURI();
  if (uri == null) {
    uri=new URI(fileName);
  }
  XSLoader xsLoader=new XMLSchemaLoader();
  XSModel xsModel=xsLoader.loadURI(uri.toString());
  ATreeNode complexTypesRoot=populateComplexTypeTree(xsModel);
  XSNamedMap map=xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
  ATreeNode root=new ATreeNode();
  root.setValue("String_Node_Str");
  for (int i=0; i < map.getLength(); i++) {
    ATreeNode node=new ATreeNode();
    XSElementDecl element=(XSElementDecl)map.item(i);
    node.setValue(element.getName());
    node.setType(ATreeNode.ELEMENT_TYPE);
    node.setDataType(element.getName());
    if (element.getTypeDefinition() instanceof XSComplexTypeDecl) {
      XSComplexTypeDecl complexType=(XSComplexTypeDecl)element.getTypeDefinition();
      if (complexType.getName() != null) {
        node.setDataType(complexType.getName());
        ATreeNode n=findComplexElement(complexTypesRoot,complexType.getName());
        if (n != null)         node.addChild(n.getChildren());
      }
 else {
        addParticleAndAttributeInfo(node,complexType,complexTypesRoot);
      }
    }
    root.addChild(node);
  }
  populateRoot(root);
  return root;
}