Program: 67190
Project: 67190
Buggy source:
/** 
 * Process a given XML composite mapping - either an XMLCompositeObjectMapping, or an  XMLCompositeCollectionMapping.  For XMLCompositeDirectCollectionMappings the  processXMLCompositeDirectCollectionMapping method should be used.
 * @param mapping
 * @param seq
 * @param ct
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param collection
 */
protected void processXMLCompositeMapping(AggregateMapping mapping,Sequence seq,ComplexType ct,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors,boolean collection){
  String refClassName=mapping.getReferenceClassName();
  XMLDescriptor refDesc=getDescriptorByName(refClassName,descriptors);
  if (refDesc == null) {
    throw DescriptorException.descriptorIsMissing(refClassName,mapping);
  }
  XPathFragment frag=((XMLField)mapping.getField()).getXPathFragment();
  seq=buildSchemaComponentsForXPath(frag,seq,schemaForNamespace,workingSchema,properties);
  frag=getTargetXPathFragment(frag);
  Element element=buildElement(frag,null,Occurs.ZERO,(collection ? Occurs.UNBOUNDED : null));
  ComplexType ctype=null;
  if (refDesc.getSchemaReference() == null) {
    ctype=buildComplexType(true,refDesc,schemaForNamespace,workingSchema,properties,descriptors);
  }
 else {
    element.setType(getSchemaTypeString(refDesc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()),workingSchema));
  }
  if (frag.getNamespaceURI() != null) {
    element=handleFragNamespace(frag,schemaForNamespace,workingSchema,properties,element,ctype,refDesc);
  }
 else   if (ctype != null) {
    element.setComplexType(ctype);
  }
  seq.addElement(element);
}

Fixed version (ground truth):
/** 
 * Process a given XML composite mapping - either an XMLCompositeObjectMapping, or an  XMLCompositeCollectionMapping.  For XMLCompositeDirectCollectionMappings the  processXMLCompositeDirectCollectionMapping method should be used.
 * @param mapping
 * @param seq
 * @param ct
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param collection
 */
protected void processXMLCompositeMapping(AggregateMapping mapping,Sequence seq,ComplexType ct,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors,boolean collection){
  String refClassName=mapping.getReferenceClassName();
  XMLDescriptor refDesc=getDescriptorByName(refClassName,descriptors);
  if (refDesc == null) {
    throw DescriptorException.descriptorIsMissing(refClassName,mapping);
  }
  XPathFragment frag=((XMLField)mapping.getField()).getXPathFragment();
  seq=buildSchemaComponentsForXPath(frag,seq,schemaForNamespace,workingSchema,properties);
  frag=getTargetXPathFragment(frag);
  Element element=buildElement(frag,null,Occurs.ZERO,(collection ? Occurs.UNBOUNDED : null));
  ComplexType ctype=null;
  if (refDesc.getSchemaReference() == null) {
    ctype=buildComplexType(true,refDesc,schemaForNamespace,workingSchema,properties,descriptors);
  }
 else {
    element.setType(getSchemaTypeString(refDesc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()),workingSchema));
  }
  if (frag.getNamespaceURI() != null) {
    element=handleFragNamespace(frag,schemaForNamespace,workingSchema,properties,element,ctype,refDesc);
  }
 else   if (ctype != null) {
    element.setComplexType(ctype);
  }
  boolean isNillable=false;
  if (!collection) {
    isNillable=((XMLCompositeObjectMapping)mapping).getNullPolicy().isNullRepresentedByXsiNil();
  }
 else {
    isNillable=((XMLCompositeCollectionMapping)mapping).getNullPolicy().isNullRepresentedByXsiNil();
  }
  element.setNillable(isNillable);
  seq.addElement(element);
}