Program: 65782
Project: 65782
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Object fieldValue=xmlDirectMapping.getFieldValue(objectValue,session,marshalRecord);
  if (null == fieldValue) {
    return xmlDirectMapping.getNullPolicy().directMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
 else {
    QName schemaType=getSchemaType((XMLField)xmlDirectMapping.getField(),fieldValue,session);
    XPathFragment groupingFragment=null;
    boolean isQName=false;
    if (XMLConstants.QNAME_QNAME.equals(schemaType)) {
      groupingFragment=openGroupingElementsForQName((QName)fieldValue,marshalRecord);
      isQName=true;
    }
    if (groupingFragment == null) {
      groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    }
    String stringValue=getValueToWrite(schemaType,fieldValue,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),marshalRecord);
    if (xPathFragment.isAttribute()) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,stringValue);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      marshalRecord.closeStartGroupingElements(groupingFragment);
      if (xmlDirectMapping.isCDATA()) {
        marshalRecord.cdata(stringValue);
      }
 else {
        marshalRecord.characters(stringValue);
      }
    }
    if (isQName) {
      XPathFragment fragment=getLastGroupingFragment();
      if (fragment != groupingFragment) {
        marshalRecord.endElement(groupingFragment,namespaceResolver);
        return false;
      }
    }
    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=xmlDirectMapping.getFieldValue(objectValue,session,marshalRecord);
  if (null == fieldValue) {
    return xmlDirectMapping.getNullPolicy().directMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
 else {
    QName schemaType=getSchemaType((XMLField)xmlDirectMapping.getField(),fieldValue,session);
    XPathFragment groupingFragment=null;
    boolean isQName=false;
    if (XMLConstants.QNAME_QNAME.equals(schemaType)) {
      groupingFragment=openGroupingElementsForQName((QName)fieldValue,marshalRecord);
      isQName=true;
    }
    if (groupingFragment == null) {
      groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    }
    if (xPathFragment.isAttribute()) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,fieldValue,schemaType);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      marshalRecord.closeStartGroupingElements(groupingFragment);
      marshalRecord.characters(schemaType,fieldValue,xmlDirectMapping.isCDATA());
    }
    if (isQName) {
      XPathFragment fragment=getLastGroupingFragment();
      if (fragment != groupingFragment) {
        marshalRecord.endElement(groupingFragment,namespaceResolver);
        return false;
      }
    }
    return true;
  }
}