Program: 67491
Project: 67491
Buggy source:
/** 
 * Process a given descriptor.  Global complex types will be generated for based on  schema context, and global elements based on default root element. 
 * @param desc
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 */
protected void processDescriptor(XMLDescriptor desc,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors){
  XMLSchemaReference schemaRef=desc.getSchemaReference();
  if (schemaRef != null) {
    if (schemaRef.getType() == org.eclipse.persistence.platform.xml.XMLSchemaReference.COMPLEX_TYPE) {
      workingSchema.addTopLevelComplexTypes(buildComplexType(false,desc,schemaForNamespace,workingSchema,properties,descriptors));
    }
 else     if (schemaRef.getType() == org.eclipse.persistence.platform.xml.XMLSchemaReference.SIMPLE_TYPE) {
      workingSchema.addTopLevelSimpleTypes(buildSimpleType(desc,workingSchema));
    }
    for (    DatabaseTable table : desc.getTables()) {
      String localName=getDefaultRootElementAsQName(desc,table.getName()).getLocalPart();
      Element topLevelElement=new Element();
      topLevelElement.setName(localName);
      QName qname=schemaRef.getSchemaContextAsQName(workingSchema.getNamespaceResolver());
      String elementType=qname.getLocalPart();
      String elementTypeUri=qname.getNamespaceURI();
      String elementTypePrefix=workingSchema.getNamespaceResolver().resolveNamespaceURI(elementTypeUri);
      if (elementTypePrefix != null) {
        elementType=elementTypePrefix + COLON + elementType;
      }
      topLevelElement.setType(elementType);
      workingSchema.addTopLevelElement(topLevelElement);
    }
  }
 else {
    for (    DatabaseTable table : desc.getTables()) {
      String localName=getDefaultRootElementAsQName(desc,table.getName()).getLocalPart();
      if (workingSchema.getTopLevelElements().get(localName) == null) {
        Element topLevelElement=new Element();
        topLevelElement.setName(localName);
        topLevelElement.setComplexType(buildComplexType(true,desc,schemaForNamespace,workingSchema,properties,descriptors));
        workingSchema.addTopLevelElement(topLevelElement);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Process a given descriptor.  Global complex types will be generated for based on  schema context, and global elements based on default root element. 
 * @param desc
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 */
protected void processDescriptor(XMLDescriptor desc,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors){
  boolean simple=isSimple(desc);
  XMLSchemaReference schemaRef=desc.getSchemaReference();
  if (schemaRef != null) {
    if (schemaRef.getType() == org.eclipse.persistence.platform.xml.XMLSchemaReference.COMPLEX_TYPE) {
      workingSchema.addTopLevelComplexTypes(buildComplexType(false,desc,schemaForNamespace,workingSchema,properties,descriptors));
    }
 else     if (schemaRef.getType() == org.eclipse.persistence.platform.xml.XMLSchemaReference.SIMPLE_TYPE) {
      workingSchema.addTopLevelSimpleTypes(buildSimpleType(desc,workingSchema,true));
    }
 else     if (schemaRef.getType() == org.eclipse.persistence.platform.xml.XMLSchemaReference.ELEMENT) {
      workingSchema.addTopLevelElement(buildElement(desc,schemaForNamespace,workingSchema,properties,descriptors,simple));
    }
    for (    DatabaseTable table : desc.getTables()) {
      String localName=getDefaultRootElementAsQName(desc,table.getName()).getLocalPart();
      if (workingSchema.getTopLevelElements().get(localName) != null) {
        continue;
      }
      Element topLevelElement=new Element();
      topLevelElement.setName(localName);
      QName qname=schemaRef.getSchemaContextAsQName(workingSchema.getNamespaceResolver());
      String elementType=qname.getLocalPart();
      String elementTypeUri=qname.getNamespaceURI();
      String elementTypePrefix=workingSchema.getNamespaceResolver().resolveNamespaceURI(elementTypeUri);
      if (elementTypePrefix != null) {
        elementType=elementTypePrefix + COLON + elementType;
      }
      topLevelElement.setType(elementType);
      workingSchema.addTopLevelElement(topLevelElement);
    }
  }
 else {
    for (    DatabaseTable table : desc.getTables()) {
      String localName=getDefaultRootElementAsQName(desc,table.getName()).getLocalPart();
      if (workingSchema.getTopLevelElements().get(localName) == null) {
        Element topLevelElement=new Element();
        topLevelElement.setName(localName);
        if (simple) {
          if (isComplexTypeWithSimpleContentRequired(desc)) {
            topLevelElement.setComplexType(buildComplexTypeWithSimpleContent(desc,schemaForNamespace,workingSchema,properties,descriptors));
          }
 else {
            topLevelElement.setSimpleType(buildSimpleType(desc,workingSchema,false));
          }
        }
 else {
          topLevelElement.setComplexType(buildComplexType(true,desc,schemaForNamespace,workingSchema,properties,descriptors));
        }
        workingSchema.addTopLevelElement(topLevelElement);
      }
    }
  }
}