Program: 65319
Project: 65319
Buggy source:
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment();
        frag.setNamespaceAware(unmarshalRecord.isNamespaceAware());
        frag.setXPath(schemaType);
        QName qname=null;
        if (frag.hasNamespace()) {
          String prefix=frag.getPrefix();
          String url=unmarshalRecord.resolveNamespacePrefix(prefix);
          frag.setNamespaceURI(url);
          qname=new QName(url,frag.getLocalName());
          unmarshalRecord.setTypeQName(qname);
        }
 else {
          String url=unmarshalRecord.resolveNamespacePrefix(XMLConstants.EMPTY_STRING);
          if (null != url) {
            frag.setNamespaceURI(url);
            qname=new QName(url,frag.getLocalName());
            unmarshalRecord.setTypeQName(qname);
          }
        }
        returnDescriptor=xmlContext.getDescriptorByGlobalType(frag);
        if (returnDescriptor == null) {
          if (policy == null || (policy != null && policy != UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT && policy != UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
            Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(qname);
            if (theClass == null) {
              throw XMLMarshalException.unknownXsiTypeValue(schemaType,mapping);
            }
          }
        }
      }
    }
  }
  return returnDescriptor;
}

Fixed version (ground truth):
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor returnDescriptor=null;
  if (atts != null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    String schemaType=null;
    if (unmarshalRecord.isNamespaceAware()) {
      schemaType=atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
 else {
      schemaType=atts.getValue(XMLConstants.EMPTY_STRING,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    }
    if (schemaType != null) {
      schemaType=schemaType.trim();
      if (schemaType.length() > 0) {
        XPathFragment frag=new XPathFragment(schemaType,unmarshalRecord.getNamespaceSeparator(),unmarshalRecord.isNamespaceAware());
        QName qname=null;
        if (frag.hasNamespace()) {
          String prefix=frag.getPrefix();
          String url=unmarshalRecord.resolveNamespacePrefix(prefix);
          frag.setNamespaceURI(url);
          qname=new QName(url,frag.getLocalName());
          unmarshalRecord.setTypeQName(qname);
        }
 else {
          String url=unmarshalRecord.resolveNamespacePrefix(XMLConstants.EMPTY_STRING);
          if (null != url) {
            frag.setNamespaceURI(url);
            qname=new QName(url,frag.getLocalName());
            unmarshalRecord.setTypeQName(qname);
          }
        }
        returnDescriptor=xmlContext.getDescriptorByGlobalType(frag);
        if (returnDescriptor == null) {
          if (policy == null || (policy != null && policy != UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT && policy != UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
            Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(qname);
            if (theClass == null) {
              throw XMLMarshalException.unknownXsiTypeValue(schemaType,mapping);
            }
          }
        }
      }
    }
  }
  return returnDescriptor;
}