Program: 67793
Project: 67793
Buggy source:
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xmlCollectionReferenceMapping.usesSingleNode()) {
    XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    if (xPathFragment.isAttribute()) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,(String)value);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      marshalRecord.closeStartGroupingElements(groupingFragment);
      marshalRecord.characters((String)value);
    }
  }
 else {
    QName schemaType;
    Object fieldValue=xmlCollectionReferenceMapping.buildFieldValue(value,xmlField,session);
    if (fieldValue == null) {
      return;
    }
    schemaType=getSchemaType(xmlField,fieldValue,session);
    String stringValue=getValueToWrite(schemaType,fieldValue,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    if (stringValue != null) {
      marshalRecord.openStartElement(xPathFragment,namespaceResolver);
      XPathFragment nextFragment=xPathFragment.getNextFragment();
      if (nextFragment.isAttribute()) {
        marshalRecord.attribute(nextFragment,namespaceResolver,stringValue);
        marshalRecord.closeStartElement();
      }
 else {
        marshalRecord.closeStartElement();
        marshalRecord.characters(stringValue);
      }
      marshalRecord.endElement(xPathFragment,namespaceResolver);
    }
  }
}

Fixed version (ground truth):
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xmlCollectionReferenceMapping.usesSingleNode()) {
    XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    if (xPathFragment.isAttribute()) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,(String)value);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      marshalRecord.closeStartGroupingElements(groupingFragment);
      marshalRecord.characters((String)value);
    }
  }
 else {
    QName schemaType;
    Object fieldValue=xmlCollectionReferenceMapping.buildFieldValue(value,xmlField,session);
    if (fieldValue == null) {
      return;
    }
    schemaType=getSchemaType(xmlField,fieldValue,session);
    String stringValue=getValueToWrite(schemaType,fieldValue,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
    if (stringValue != null) {
      marshalRecord.openStartElement(xPathFragment,namespaceResolver);
      XPathFragment nextFragment=xPathFragment.getNextFragment();
      if (nextFragment.isAttribute()) {
        marshalRecord.attribute(nextFragment,namespaceResolver,stringValue);
        marshalRecord.closeStartElement();
      }
 else {
        marshalRecord.closeStartElement();
        marshalRecord.characters(stringValue);
      }
      marshalRecord.endElement(xPathFragment,namespaceResolver);
    }
  }
}