Program: 66534
Project: 66534
Buggy source:
/** 
 * Process a given XMLObjectReferenceMapping.  In the case of an XMLCollectionReferenceMapping,  i.e. the isCollection flag is set to true, maxOccurs will be set to 'unbounded' on any  source elements 
 * @param mapping
 * @param seq
 * @param ct
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param isCollection
 */
protected void processXMLObjectReferenceMapping(XMLObjectReferenceMapping mapping,Sequence seq,ComplexType ct,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors,boolean isCollection){
  String tgtClassName=mapping.getReferenceClassName();
  XMLDescriptor tgtDesc=getDescriptorByName(tgtClassName,descriptors);
  if (tgtDesc == null) {
    throw DescriptorException.descriptorIsMissing(tgtClassName,mapping);
  }
  String schemaTypeString=null;
  Map<XMLField,XMLField> associations=mapping.getSourceToTargetKeyFieldAssociations();
  for (  XMLField srcField : associations.keySet()) {
    XMLField tgtField=associations.get(srcField);
    Vector mappings=tgtDesc.getMappings();
    for (Enumeration mappingsNum=mappings.elements(); mappingsNum.hasMoreElements(); ) {
      DatabaseMapping dbMapping=(DatabaseMapping)mappingsNum.nextElement();
      if (dbMapping.getField() != null && dbMapping.getField() instanceof XMLField) {
        XMLField xFld=(XMLField)dbMapping.getField();
        if (xFld == tgtField) {
          schemaTypeString=getSchemaTypeForElement(tgtField,dbMapping.getAttributeClassification(),workingSchema);
        }
      }
    }
    if (schemaTypeString == null) {
      schemaTypeString=getSchemaTypeString(XMLConstants.STRING_QNAME,workingSchema);
    }
    XPathFragment frag=srcField.getXPathFragment();
    if (frag.isAttribute()) {
      Attribute attr=buildAttribute(frag,schemaTypeString);
      ct.getOrderedAttributes().add(attr);
    }
 else {
      Element elem=buildElement(frag,schemaTypeString,Occurs.ZERO,null);
      if (isCollection) {
        elem.setMaxOccurs(Occurs.UNBOUNDED);
      }
      seq.addElement(elem);
    }
  }
}

Fixed version (ground truth):
/** 
 * Process a given XMLObjectReferenceMapping.  In the case of an XMLCollectionReferenceMapping,  i.e. the isCollection flag is set to true, maxOccurs will be set to 'unbounded' on any  source elements 
 * @param mapping
 * @param seq
 * @param ct
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param isCollection
 */
protected void processXMLObjectReferenceMapping(XMLObjectReferenceMapping mapping,Sequence seq,ComplexType ct,HashMap<String,Schema> schemaForNamespace,Schema workingSchema,SchemaModelGeneratorProperties properties,List<XMLDescriptor> descriptors,boolean isCollection){
  String tgtClassName=mapping.getReferenceClassName();
  XMLDescriptor tgtDesc=getDescriptorByName(tgtClassName,descriptors);
  if (tgtDesc == null) {
    throw DescriptorException.descriptorIsMissing(tgtClassName,mapping);
  }
  String schemaTypeString=null;
  Map<XMLField,XMLField> associations=mapping.getSourceToTargetKeyFieldAssociations();
  for (  Entry<XMLField,XMLField> entry : associations.entrySet()) {
    XMLField tgtField=entry.getValue();
    Vector mappings=tgtDesc.getMappings();
    for (Enumeration mappingsNum=mappings.elements(); mappingsNum.hasMoreElements(); ) {
      DatabaseMapping dbMapping=(DatabaseMapping)mappingsNum.nextElement();
      if (dbMapping.getField() != null && dbMapping.getField() instanceof XMLField) {
        XMLField xFld=(XMLField)dbMapping.getField();
        if (xFld == tgtField) {
          schemaTypeString=getSchemaTypeForElement(tgtField,dbMapping.getAttributeClassification(),workingSchema);
        }
      }
    }
    if (schemaTypeString == null) {
      schemaTypeString=getSchemaTypeString(XMLConstants.STRING_QNAME,workingSchema);
    }
    XPathFragment frag=entry.getKey().getXPathFragment();
    if (frag.isAttribute()) {
      Attribute attr=buildAttribute(frag,schemaTypeString);
      ct.getOrderedAttributes().add(attr);
    }
 else {
      Element elem=buildElement(frag,schemaTypeString,Occurs.ZERO,null);
      if (isCollection) {
        elem.setMaxOccurs(Occurs.UNBOUNDED);
      }
      seq.addElement(elem);
    }
  }
}