Program: 65438
Project: 65438
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Object fieldValue=directMapping.getFieldValue(objectValue,session);
  if ((null == fieldValue) || (null == namespaceResolver)) {
    return false;
  }
  XMLField xmlField=(XMLField)directMapping.getField();
  QName schemaType=getSchemaType(xmlField,fieldValue,session);
  if (null == schemaType) {
    return false;
  }
  if (xmlField.getSchemaType() == null) {
    if (schemaType.equals(XMLConstants.STRING_QNAME)) {
      return false;
    }
  }
 else {
    if (xmlField.isSchemaType(schemaType)) {
      return false;
    }
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  String typeQName=namespaceResolver.resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL) + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE;
  String schemaTypePrefix=namespaceResolver.resolveNamespaceURI(schemaType.getNamespaceURI());
  if (schemaTypePrefix == null) {
    if (XMLConstants.SCHEMA_URL.equals(schemaType.getNamespaceURI())) {
      schemaTypePrefix=namespaceResolver.generatePrefix(XMLConstants.SCHEMA_PREFIX);
    }
 else {
      schemaTypePrefix=namespaceResolver.generatePrefix();
    }
    marshalRecord.attribute(XMLConstants.XMLNS_URL,schemaTypePrefix,XMLConstants.XMLNS + XMLConstants.COLON + schemaTypePrefix,schemaType.getNamespaceURI());
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeQName,schemaTypePrefix + XMLConstants.COLON + schemaType.getLocalPart());
  marshalRecord.closeStartGroupingElements(groupingFragment);
  return true;
}

Fixed version (ground truth):
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Object fieldValue=directMapping.getFieldValue(objectValue,session);
  if ((null == fieldValue) || (null == namespaceResolver)) {
    return false;
  }
  XMLField xmlField=(XMLField)directMapping.getField();
  QName schemaType=getSchemaType(xmlField,fieldValue,session);
  if (null == schemaType) {
    return false;
  }
  if (xmlField.getSchemaType() == null) {
    if (schemaType.equals(XMLConstants.STRING_QNAME)) {
      return false;
    }
  }
 else {
    if (xmlField.isSchemaType(schemaType)) {
      return false;
    }
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  String typeQName=namespaceResolver.resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL) + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE;
  String schemaTypePrefix=namespaceResolver.resolveNamespaceURI(schemaType.getNamespaceURI());
  if (schemaTypePrefix == null) {
    if (XMLConstants.SCHEMA_URL.equals(schemaType.getNamespaceURI())) {
      schemaTypePrefix=namespaceResolver.generatePrefix(XMLConstants.SCHEMA_PREFIX);
    }
 else {
      schemaTypePrefix=namespaceResolver.generatePrefix();
    }
    marshalRecord.namespaceDeclaration(schemaTypePrefix,schemaType.getNamespaceURI());
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeQName,schemaTypePrefix + XMLConstants.COLON + schemaType.getLocalPart());
  marshalRecord.closeStartGroupingElements(groupingFragment);
  return true;
}