Program: 77286
Project: 77286
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);
  if (f.exists())   uri=f.toURI();
 else {
    URL url=new URL(fileName);
    uri=new URI(url.getProtocol(),url.getUserInfo(),url.getHost(),url.getPort(),url.getPath(),url.getQuery(),url.getRef());
  }
  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;
}

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);
  if (f.exists())   uri=f.toURI();
 else {
    URL url=new URL(fileName);
    uri=new URI(url.getProtocol(),url.getUserInfo(),url.getHost(),url.getPort(),url.getPath(),url.getQuery(),url.getRef());
  }
  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,new VisitingRecorder());
      }
    }
    root.addChild(node);
  }
  populateRoot(root);
  return root;
}