nus-yam/ex-repair huggingface dataset:
Program: 67274
Project: 67274
Buggy source:
protected void reportElementEvents(Element elem) throws SAXException {
  this.currentNode=elem;
  IndexedAttributeList attributes=buildAttributeList(elem);
  String qname;
  String lname=elem.getLocalName();
  if (lname == null) {
    lname=elem.getNodeName();
    qname=lname;
  }
 else {
    qname=getQName(elem);
  }
  getContentHandler().startElement(elem.getNamespaceURI(),lname,qname,attributes);
  handleChildNodes(elem.getChildNodes());
  endPrefixMappings(elem);
  getContentHandler().endElement(elem.getNamespaceURI(),lname,qname);
}

Fixed version (ground truth):
protected void reportElementEvents(Element elem) throws SAXException {
  this.currentNode=elem;
  IndexedAttributeList attributes=buildAttributeList(elem);
  String qname;
  String lname=elem.getLocalName();
  if (lname == null) {
    lname=elem.getNodeName();
    qname=lname;
  }
 else {
    qname=getQName(elem);
  }
  getContentHandler().startElement(elem.getNamespaceURI(),lname,qname,attributes);
  handleChildNodes(elem.getChildNodes());
  getContentHandler().endElement(elem.getNamespaceURI(),lname,qname);
  endPrefixMappings(elem);
}
Program: 67275
Project: 67275
Buggy source:
public void setDOM(Element element){
  this.dom=element;
  this.getNamespaceResolver().setDOM(element);
}

Fixed version (ground truth):
public void setDOM(Element element){
  this.dom=element;
  this.currentNode=element;
  this.getNamespaceResolver().setDOM(element);
}
Program: 67276
Project: 67276
Buggy source:
private Object convertValue(Element node,XMLField key,Object value){
  XMLConversionManager xmlCnvMgr=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
  if (key.isTypedTextField() && (node != null)) {
    String schemaType=node.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if ((null != schemaType) && (!schemaType.equals("String_Node_Str"))) {
      QName qname=null;
      int index=schemaType.indexOf(':');
      if (index == -1) {
        qname=new QName(schemaType);
        Class convertClass=key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value,convertClass);
      }
 else {
        String prefix=schemaType.substring(0,index);
        String localPart=schemaType.substring(index + 1);
        XMLPlatform xmlPlatform=XMLPlatformFactory.getInstance().getXMLPlatform();
        String url=xmlPlatform.resolveNamespacePrefix(node,prefix);
        qname=new QName(url,localPart);
        Class convertClass=key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value,convertClass,qname);
      }
    }
  }
  return key.convertValueBasedOnSchemaType(value,xmlCnvMgr,this);
}

Fixed version (ground truth):
private Object convertValue(Element node,XMLField key,Object value){
  XMLConversionManager xmlCnvMgr=(XMLConversionManager)session.getDatasourcePlatform().getConversionManager();
  if (key.isTypedTextField() && (node != null)) {
    String schemaType=node.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if ((null != schemaType) && (!schemaType.equals("String_Node_Str"))) {
      QName qname=null;
      int index=schemaType.indexOf(':');
      if (index == -1) {
        qname=new QName(schemaType);
        Class convertClass=key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value,convertClass);
      }
 else {
        String prefix=schemaType.substring(0,index);
        String localPart=schemaType.substring(index + 1);
        XMLPlatform xmlPlatform=XMLPlatformFactory.getInstance().getXMLPlatform();
        String url=xmlPlatform.resolveNamespacePrefix(node,prefix);
        qname=new QName(url,localPart);
        Class convertClass=key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value,convertClass,qname);
      }
    }
  }
  currentNode=node;
  Object convertedValue=key.convertValueBasedOnSchemaType(value,xmlCnvMgr,this);
  currentNode=getDOM();
  return convertedValue;
}
Program: 67277
Project: 67277
Buggy source:
public String resolveNamespacePrefix(String prefix){
  XMLPlatform xmlPlatform=XMLPlatformFactory.getInstance().getXMLPlatform();
  return xmlPlatform.resolveNamespacePrefix(this.getDOM(),prefix);
}

Fixed version (ground truth):
public String resolveNamespacePrefix(String prefix){
  XMLPlatform xmlPlatform=XMLPlatformFactory.getInstance().getXMLPlatform();
  return xmlPlatform.resolveNamespacePrefix(currentNode,prefix);
}
Program: 67278
Project: 67278
Buggy source:
/** 
 * PUBLIC: Clear the sub-nodes of the DOM.
 */
public void clear(){
  if (getDOM() instanceof Element) {
    String domName=((Element)getDOM()).getTagName();
    this.dom=createNewDocument(domName,null);
  }
}

Fixed version (ground truth):
/** 
 * PUBLIC: Clear the sub-nodes of the DOM.
 */
public void clear(){
  if (getDOM() instanceof Element) {
    String domName=((Element)getDOM()).getTagName();
    this.dom=createNewDocument(domName,null);
    this.currentNode=this.dom;
  }
}
Program: 67279
Project: 67279
Buggy source:
private Object getValueFromAttribute(Attr node,XMLField key){
  return key.convertValueBasedOnSchemaType(node.getNodeValue(),(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),this);
}

Fixed version (ground truth):
private Object getValueFromAttribute(Attr node,XMLField key){
  currentNode=node.getOwnerElement();
  Object convertedValue=key.convertValueBasedOnSchemaType(node.getNodeValue(),(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),this);
  currentNode=getDOM();
  return convertedValue;
}
Program: 67281
Project: 67281
Buggy source:
public void pop(String prefix){
  if (null == namespaceMap) {
    return;
  }
  Stack uriStack=(Stack)namespaceMap.get(prefix);
  String uri=null;
  if (uriStack != null && uriStack.size() > 0) {
    uri=(String)uriStack.pop();
  }
  if (uri != null && uriToPrefixMap != null) {
    Stack prefixStack=(Stack)uriToPrefixMap.get(uri);
    if (prefixStack != null && prefixStack.size() > 0) {
      prefixStack.pop();
    }
  }
}

Fixed version (ground truth):
public void pop(String prefix){
  if (null == namespaceMap) {
    return;
  }
  Stack<String> uriStack=namespaceMap.get(prefix);
  String uri=null;
  if (uriStack != null && uriStack.size() > 0) {
    uri=uriStack.pop();
  }
  if (uri != null && uriToPrefixMap != null) {
    Stack<String> prefixStack=uriToPrefixMap.get(uri);
    if (prefixStack != null && prefixStack.size() > 0) {
      prefixStack.pop();
    }
  }
}
Program: 67282
Project: 67282
Buggy source:
public String getPrefix(String namespaceURI){
  String prefix=null;
  if (null == prefix && null != uriToPrefixMap) {
    Stack prefixStack=(Stack)uriToPrefixMap.get(namespaceURI);
    if (prefixStack != null && prefixStack.size() > 0) {
      prefix=(String)prefixStack.peek();
    }
  }
  return prefix;
}

Fixed version (ground truth):
public String getPrefix(String namespaceURI){
  String prefix=null;
  if (null == prefix && null != uriToPrefixMap) {
    Stack<String> prefixStack=uriToPrefixMap.get(namespaceURI);
    if (prefixStack != null && prefixStack.size() > 0) {
      prefix=prefixStack.peek();
    }
  }
  return prefix;
}
Program: 67283
Project: 67283
Buggy source:
public String getNamespaceURI(String prefix){
  String namespaceURI=null;
  if (prefix == null) {
    prefix="String_Node_Str";
  }
  if (null != namespaceMap) {
    Stack uriStack=(Stack)namespaceMap.get(prefix);
    if (uriStack != null && uriStack.size() > 0) {
      namespaceURI=(String)uriStack.peek();
    }
  }
  return namespaceURI;
}

Fixed version (ground truth):
public String getNamespaceURI(String prefix){
  String namespaceURI=null;
  if (prefix == null) {
    prefix="String_Node_Str";
  }
  if (null != namespaceMap) {
    Stack<String> uriStack=namespaceMap.get(prefix);
    if (uriStack != null && uriStack.size() > 0) {
      namespaceURI=uriStack.peek();
    }
  }
  return namespaceURI;
}
Program: 67284
Project: 67284
Buggy source:
public void push(String prefix,String namespaceURI){
  if (null == namespaceMap) {
    namespaceMap=new HashMap();
  }
  if (uriToPrefixMap == null) {
    uriToPrefixMap=new HashMap();
  }
  Stack uriStack=(Stack)namespaceMap.get(prefix);
  if (uriStack == null) {
    uriStack=new Stack();
    namespaceMap.put(prefix,uriStack);
  }
  uriStack.push(namespaceURI);
  Stack prefixStack=(Stack)uriToPrefixMap.get(namespaceURI);
  if (prefixStack == null) {
    prefixStack=new Stack();
    uriToPrefixMap.put(namespaceURI,prefixStack);
  }
  prefixStack.push(prefix);
}

Fixed version (ground truth):
public void push(String prefix,String namespaceURI){
  if (null == namespaceMap) {
    namespaceMap=new HashMap<String,Stack<String>>();
  }
  if (uriToPrefixMap == null) {
    uriToPrefixMap=new HashMap<String,Stack<String>>();
  }
  Stack uriStack=namespaceMap.get(prefix);
  if (uriStack == null) {
    uriStack=new Stack<String>();
    namespaceMap.put(prefix,uriStack);
  }
  uriStack.push(namespaceURI);
  Stack<String> prefixStack=uriToPrefixMap.get(namespaceURI);
  if (prefixStack == null) {
    prefixStack=new Stack<String>();
    uriToPrefixMap.put(namespaceURI,prefixStack);
  }
  prefixStack.push(prefix);
}
Program: 67285
Project: 67285
Buggy source:
public UnmarshalNamespaceContext(NamespaceContext aNamespaceContext){
  this.namespaceContext=aNamespaceContext;
  this.prefixes=new HashSet();
}

Fixed version (ground truth):
public UnmarshalNamespaceContext(XMLStreamReader anXMLStreamReader){
  this.xmlStreamReader=anXMLStreamReader;
  this.prefixes=new HashSet();
}
Program: 67286
Project: 67286
Buggy source:
/** 
 * The underlying NamespaceContext is responsible for maintaining the  appropriate prefix/URI associations.
 */
public void pop(String prefix){
  if (null != namespaceContext.getNamespaceURI(prefix)) {
    prefixes.remove(prefix);
  }
}

Fixed version (ground truth):
/** 
 * The underlying NamespaceContext is responsible for maintaining the  appropriate prefix/URI associations.
 */
public void pop(String prefix){
  if (null != getNamespaceURI(prefix)) {
    prefixes.remove(prefix);
  }
}
Program: 67287
Project: 67287
Buggy source:
public String getPrefix(String namespaceURI){
  return namespaceContext.getPrefix(namespaceURI);
}

Fixed version (ground truth):
public String getPrefix(String namespaceURI){
  return xmlStreamReader.getNamespaceContext().getPrefix(namespaceURI);
}
Program: 67288
Project: 67288
Buggy source:
public String getNamespaceURI(String prefix){
  if (null == prefix) {
    prefix="String_Node_Str";
  }
  return namespaceContext.getNamespaceURI(prefix);
}

Fixed version (ground truth):
public String getNamespaceURI(String prefix){
  if (null == prefix) {
    prefix="String_Node_Str";
  }
  return xmlStreamReader.getNamespaceURI(prefix);
}
Program: 67289
Project: 67289
Buggy source:
public void endPrefixMapping(String prefix) throws SAXException {
  unmarshalNamespaceResolver.pop(prefix);
}

Fixed version (ground truth):
public void endPrefixMapping(String prefix) throws SAXException {
  getUnmarshalNamespaceResolver().pop(prefix);
}
Program: 67290
Project: 67290
Buggy source:
public void startPrefixMapping(String prefix,String uri) throws SAXException {
  unmarshalNamespaceResolver.push(prefix,uri);
}

Fixed version (ground truth):
public void startPrefixMapping(String prefix,String uri) throws SAXException {
  getUnmarshalNamespaceResolver().push(prefix,uri);
}
Program: 67291
Project: 67291
Buggy source:
public UnmarshalRecord(TreeObjectBuilder treeObjectBuilder){
  super();
  this.levelIndex=0;
  this.xPathFragment=new XPathFragment();
  this.stringBuffer=new StrBuffer();
  this.isBufferCDATA=false;
  this.treeObjectBuilder=treeObjectBuilder;
  nullCapableValues=new ArrayList();
  if (null != treeObjectBuilder) {
    this.xPathNode=treeObjectBuilder.getRootXPathNode();
    if (null != treeObjectBuilder.getNullCapableValues()) {
      nullCapableValues.addAll(treeObjectBuilder.getNullCapableValues());
    }
  }
  fragmentBuilder=new SAXFragmentBuilder(this);
  isSelfRecord=false;
  unmarshalNamespaceResolver=new StackUnmarshalNamespaceResolver();
}

Fixed version (ground truth):
public UnmarshalRecord(TreeObjectBuilder treeObjectBuilder){
  super();
  this.levelIndex=0;
  this.xPathFragment=new XPathFragment();
  this.stringBuffer=new StrBuffer();
  this.isBufferCDATA=false;
  this.treeObjectBuilder=treeObjectBuilder;
  nullCapableValues=new ArrayList();
  if (null != treeObjectBuilder) {
    this.xPathNode=treeObjectBuilder.getRootXPathNode();
    if (null != treeObjectBuilder.getNullCapableValues()) {
      nullCapableValues.addAll(treeObjectBuilder.getNullCapableValues());
    }
  }
  fragmentBuilder=new SAXFragmentBuilder(this);
  isSelfRecord=false;
}
Program: 67292
Project: 67292
Buggy source:
public UnmarshalNamespaceResolver getUnmarshalNamespaceResolver(){
  return this.unmarshalNamespaceResolver;
}

Fixed version (ground truth):
public UnmarshalNamespaceResolver getUnmarshalNamespaceResolver(){
  if (null == unmarshalNamespaceResolver) {
    this.unmarshalNamespaceResolver=new StackUnmarshalNamespaceResolver();
  }
  return this.unmarshalNamespaceResolver;
}
Program: 67293
Project: 67293
Buggy source:
public void complexSimpleCaseInSelectTest(){
  EntityManager em=createEntityManager();
  Vector expectedResult=new Vector(12);
  expectedResult.add("String_Node_Str");
  expectedResult.add("String_Node_Str");
  for (int i=0; i < 13; i++) {
    expectedResult.add("String_Node_Str");
  }
  clearCache();
  String ejbqlString="String_Node_Str";
  List result=(List)em.createQuery(ejbqlString).getResultList();
  Assert.assertTrue("String_Node_Str",comparer.compareObjects(result,expectedResult));
}

Fixed version (ground truth):
public void complexSimpleCaseInSelectTest(){
  EntityManager em=createEntityManager();
  Vector expectedResult=new Vector(2);
  expectedResult.add("String_Node_Str");
  expectedResult.add("String_Node_Str");
  clearCache();
  String ejbqlString="String_Node_Str";
  List result=(List)em.createQuery(ejbqlString).getResultList();
  Assert.assertTrue("String_Node_Str",comparer.compareObjects(result,expectedResult));
}
Program: 67294
Project: 67294
Buggy source:
public void complexConditionCaseInSelectTest(){
  EntityManager em=createEntityManager();
  Vector expectedResult=new Vector(12);
  expectedResult.add("String_Node_Str");
  expectedResult.add("String_Node_Str");
  for (int i=0; i < 13; i++) {
    expectedResult.add("String_Node_Str");
  }
  clearCache();
  String ejbqlString="String_Node_Str";
  List result=(List)em.createQuery(ejbqlString).getResultList();
  Assert.assertTrue("String_Node_Str",comparer.compareObjects(result,expectedResult));
}

Fixed version (ground truth):
public void complexConditionCaseInSelectTest(){
  EntityManager em=createEntityManager();
  Vector expectedResult=new Vector(2);
  expectedResult.add("String_Node_Str");
  expectedResult.add("String_Node_Str");
  clearCache();
  String ejbqlString="String_Node_Str";
  List result=(List)em.createQuery(ejbqlString).getResultList();
  Assert.assertTrue("String_Node_Str",comparer.compareObjects(result,expectedResult));
}
Program: 67296
Project: 67296
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField=(XMLField)xmlDirectMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  Object value=unmarshalRecord.getStringBuffer().toString();
  if (value.equals(EMPTY_STRING)) {
    value=null;
  }
  unmarshalRecord.resetStringBuffer();
  XMLConversionManager xmlConversionManager=(XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager();
  if (unmarshalRecord.getTypeQName() != null) {
    Class typeClass=xmlField.getJavaClass(unmarshalRecord.getTypeQName());
    value=xmlConversionManager.convertObject(value,typeClass,unmarshalRecord.getTypeQName());
  }
 else {
    value=xmlField.convertValueBasedOnSchemaType(value,xmlConversionManager,unmarshalRecord);
  }
  Object convertedValue=xmlDirectMapping.getAttributeValue(value,unmarshalRecord.getSession(),unmarshalRecord);
  unmarshalRecord.setAttributeValue(convertedValue,xmlDirectMapping);
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField=(XMLField)xmlDirectMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  Object value=unmarshalRecord.getStringBuffer().toString();
  unmarshalRecord.resetStringBuffer();
  XMLConversionManager xmlConversionManager=(XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager();
  if (unmarshalRecord.getTypeQName() != null) {
    Class typeClass=xmlField.getJavaClass(unmarshalRecord.getTypeQName());
    value=xmlConversionManager.convertObject(value,typeClass,unmarshalRecord.getTypeQName());
  }
 else {
    value=xmlField.convertValueBasedOnSchemaType(value,xmlConversionManager,unmarshalRecord);
  }
  Object convertedValue=xmlDirectMapping.getAttributeValue(value,unmarshalRecord.getSession(),unmarshalRecord);
  unmarshalRecord.setAttributeValue(convertedValue,xmlDirectMapping);
}
Program: 67297
Project: 67297
Buggy source:
public boolean isWhitespaceAware(){
  return xmlDirectMapping.isWhitespacePreserved();
}

Fixed version (ground truth):
public boolean isWhitespaceAware(){
  return !xmlDirectMapping.getNullPolicy().isNullRepresentedByEmptyNode();
}
Program: 67299
Project: 67299
Buggy source:
public Object getNonAttributeChild(int index,XPathNode xPathNode){
  Setting setting=settings.get(index);
  if (null == setting.getName()) {
    return xPathNode.getNonAttributeChildrenMap().get(null);
  }
 else {
    indexFragment.setLocalName(null);
    indexFragment.setXPath(setting.getName());
    indexFragment.setNamespaceURI(setting.getNamespaceURI());
    return xPathNode.getNonAttributeChildrenMap().get(indexFragment);
  }
}

Fixed version (ground truth):
public Object getNonAttributeChild(int index,XPathNode xPathNode){
  Setting setting=settings.get(index);
  if (null == setting.getName()) {
    return xPathNode.getNonAttributeChildrenMap().get(null);
  }
 else {
    if (setting.getName().equals("String_Node_Str")) {
      return xPathNode.getTextNode();
    }
 else {
      indexFragment.setLocalName(null);
      indexFragment.setXPath(setting.getName());
      indexFragment.setNamespaceURI(setting.getNamespaceURI());
      return xPathNode.getNonAttributeChildrenMap().get(indexFragment);
    }
  }
}
Program: 67300
Project: 67300
Buggy source:
/** 
 * INTERNAL: Allows for subclasses to convert the attribute value.
 */
public Object getAttributeValue(Object fieldValue,AbstractSession session,XMLRecord record){
  if (EMPTY_STRING.equals(fieldValue)) {
    fieldValue=null;
  }
  Object attributeValue=fieldValue;
  if (attributeValue == XMLRecord.noEntry) {
    if (!getNullPolicy().getIsSetPerformedForAbsentNode()) {
      return attributeValue;
    }
 else {
      fieldValue=null;
      attributeValue=null;
    }
  }
  if (hasConverter()) {
    if (getConverter() instanceof XMLConverter) {
      attributeValue=((XMLConverter)getConverter()).convertDataValueToObjectValue(attributeValue,session,record.getUnmarshaller());
    }
 else {
      attributeValue=getConverter().convertDataValueToObjectValue(attributeValue,session);
    }
  }
 else {
    if ((attributeValue == null) || (attributeValue.getClass() != this.attributeObjectClassification)) {
      try {
        attributeValue=session.getDatasourcePlatform().convertObject(attributeValue,this.attributeClassification);
      }
 catch (      ConversionException e) {
        throw ConversionException.couldNotBeConverted(this,getDescriptor(),e);
      }
    }
  }
  if (attributeValue == null) {
    attributeValue=this.nullValue;
  }
  return attributeValue;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Allows for subclasses to convert the attribute value.
 */
public Object getAttributeValue(Object fieldValue,AbstractSession session,XMLRecord record){
  boolean isNullRepresentedByEmptyNode=getNullPolicy().isNullRepresentedByEmptyNode();
  if (EMPTY_STRING.equals(fieldValue) && isNullRepresentedByEmptyNode) {
    fieldValue=null;
  }
 else   if (null == fieldValue && !isNullRepresentedByEmptyNode) {
    fieldValue=EMPTY_STRING;
  }
  Object attributeValue=fieldValue;
  if (attributeValue == XMLRecord.noEntry) {
    if (!getNullPolicy().getIsSetPerformedForAbsentNode()) {
      return attributeValue;
    }
 else {
      fieldValue=null;
      attributeValue=null;
    }
  }
  if (hasConverter()) {
    if (getConverter() instanceof XMLConverter) {
      attributeValue=((XMLConverter)getConverter()).convertDataValueToObjectValue(attributeValue,session,record.getUnmarshaller());
    }
 else {
      attributeValue=getConverter().convertDataValueToObjectValue(attributeValue,session);
    }
  }
 else {
    if ((attributeValue == null) || (attributeValue.getClass() != this.attributeObjectClassification)) {
      try {
        attributeValue=session.getDatasourcePlatform().convertObject(attributeValue,this.attributeClassification);
      }
 catch (      ConversionException e) {
        throw ConversionException.couldNotBeConverted(this,getDescriptor(),e);
      }
    }
  }
  if (attributeValue == null) {
    attributeValue=this.nullValue;
  }
  return attributeValue;
}
Program: 67301
Project: 67301
Buggy source:
public XMLDirectMapping(){
  super();
  nullPolicy=new NullPolicy();
  isCDATA=false;
  isWhitespacePreserved=false;
}

Fixed version (ground truth):
public XMLDirectMapping(){
  super();
  nullPolicy=new NullPolicy();
  nullPolicy.setNullRepresentedByEmptyNode(true);
  isCDATA=false;
}
Program: 67302
Project: 67302
Buggy source:
public void characters(char[] ch,int start,int length) throws SAXException {
  try {
    if (null != selfRecords) {
      int selfRecordsSize=selfRecords.size();
      for (int x=0; x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=((UnmarshalRecord)selfRecords.get(x));
        if (selfRecord != null) {
          selfRecord.characters(ch,start,length);
        }
      }
    }
    XPathNode textNode=null;
    if (null != xPathNode.getNonAttributeChildrenMap()) {
      textNode=(XPathNode)xPathNode.getNonAttributeChildrenMap().get(XPathFragment.TEXT_FRAGMENT);
      if (null == textNode) {
        textNode=(XPathNode)xPathNode.getNonAttributeChildrenMap().get(XPathFragment.ANY_FRAGMENT);
        if (textNode != null) {
          if (0 == length) {
            return;
          }
          String tmpString=new String(ch,start,length);
          if (EMPTY_STRING.equals(tmpString.trim()) && !textNode.isWhitespaceAware()) {
            return;
          }
        }
      }
    }
    if (null != textNode) {
      xPathNode=textNode;
      unmarshalContext.characters(this);
    }
    if (null != xPathNode.getUnmarshalNodeValue()) {
      stringBuffer.append(ch,start,length);
    }
  }
 catch (  EclipseLinkException e) {
    if (null == xmlReader.getErrorHandler()) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(null,null,null,0,0,e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}

Fixed version (ground truth):
public void characters(char[] ch,int start,int length) throws SAXException {
  try {
    if (null != selfRecords) {
      int selfRecordsSize=selfRecords.size();
      for (int x=0; x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=((UnmarshalRecord)selfRecords.get(x));
        if (selfRecord != null) {
          selfRecord.characters(ch,start,length);
        }
      }
    }
    XPathNode textNode=xPathNode.getTextNode();
    if (null == textNode && xPathNode.getNonAttributeChildrenMap() != null) {
      textNode=(XPathNode)xPathNode.getNonAttributeChildrenMap().get(XPathFragment.ANY_FRAGMENT);
      if (textNode != null) {
        if (0 == length) {
          return;
        }
        String tmpString=new String(ch,start,length);
        if (EMPTY_STRING.equals(tmpString.trim()) && !textNode.isWhitespaceAware()) {
          return;
        }
      }
    }
    if (null != textNode) {
      xPathNode=textNode;
      unmarshalContext.characters(this);
    }
    if (null != xPathNode.getUnmarshalNodeValue()) {
      stringBuffer.append(ch,start,length);
    }
  }
 catch (  EclipseLinkException e) {
    if (null == xmlReader.getErrorHandler()) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(null,null,null,0,0,e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}
Program: 67304
Project: 67304
Buggy source:
private void processClass(JavaClass javaClass,ArrayList<JavaClass> classesToProcess){
  if (shouldGenerateTypeInfo(javaClass)) {
    if (helper.isAnnotationPresent(javaClass,XmlRegistry.class)) {
      this.processObjectFactory(javaClass,classesToProcess);
    }
 else {
      classesToProcess.add(javaClass);
      Class xmlSeeAlsoClass=null;
      Method valueMethod=null;
      try {
        xmlSeeAlsoClass=PrivilegedAccessHelper.getClassForName("String_Node_Str");
        valueMethod=PrivilegedAccessHelper.getDeclaredMethod(xmlSeeAlsoClass,"String_Node_Str",new Class[]{});
      }
 catch (      ClassNotFoundException ex) {
      }
catch (      NoSuchMethodException ex) {
      }
      if (xmlSeeAlsoClass != null && helper.isAnnotationPresent(javaClass,xmlSeeAlsoClass)) {
        Object seeAlso=helper.getAnnotation(javaClass,xmlSeeAlsoClass);
        Class[] values=null;
        try {
          values=(Class[])PrivilegedAccessHelper.invokeMethod(valueMethod,seeAlso,new Object[]{});
        }
 catch (        Exception ex) {
        }
        for (        Class next : values) {
          classesToProcess.add(helper.getJavaClass(next));
        }
      }
      for (Iterator<JavaClass> jClassIt=javaClass.getDeclaredClasses().iterator(); jClassIt.hasNext(); ) {
        JavaClass innerClass=jClassIt.next();
        if (shouldGenerateTypeInfo(innerClass)) {
          if (!(helper.isAnnotationPresent(innerClass,XmlTransient.class))) {
            classesToProcess.add(innerClass);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds additional classes to the given List, from inner classes, 
 * @XmlRegistry or @XmlSeeAlso.
 * @param javaClass
 * @param classesToProcess
 */
private void processClass(JavaClass javaClass,ArrayList<JavaClass> classesToProcess){
  if (shouldGenerateTypeInfo(javaClass)) {
    if (helper.isAnnotationPresent(javaClass,XmlRegistry.class)) {
      this.processObjectFactory(javaClass,classesToProcess);
    }
 else {
      classesToProcess.add(javaClass);
      TypeInfo info=typeInfo.get(javaClass.getQualifiedName());
      if (info != null && info.isSetXmlSeeAlso()) {
        for (        String jClassName : info.getXmlSeeAlso()) {
          classesToProcess.add(helper.getJavaClass(jClassName));
        }
      }
      for (Iterator<JavaClass> jClassIt=javaClass.getDeclaredClasses().iterator(); jClassIt.hasNext(); ) {
        JavaClass innerClass=jClassIt.next();
        if (shouldGenerateTypeInfo(innerClass)) {
          if (!(helper.isAnnotationPresent(innerClass,XmlTransient.class))) {
            classesToProcess.add(innerClass);
          }
        }
      }
    }
  }
}
Program: 67306
Project: 67306
Buggy source:
private void validateXmlValueFieldOrProperty(JavaClass cls,Property property,JavaClass ptype,String propName){
  JavaClass parent=cls.getSuperclass();
  while (parent != null && !(parent.getQualifiedName().equals("String_Node_Str"))) {
    TypeInfo parentTypeInfo=typeInfo.get(parent.getQualifiedName());
    if (parentTypeInfo == null && shouldGenerateTypeInfo(parent)) {
      parentTypeInfo=createTypeInfoFor(parent);
    }
    if (parentTypeInfo != null) {
      throw JAXBException.propertyOrFieldCannotBeXmlValue(propName);
    }
    parent=parent.getSuperclass();
  }
  JavaClass theClass;
  if (isCollectionType(property)) {
    theClass=property.getGenericType();
  }
 else   if (ptype.isArray()) {
    theClass=ptype.getComponentType();
  }
 else {
    theClass=ptype;
  }
  QName schemaQName=getSchemaTypeOrNullFor(theClass);
  if (schemaQName == null) {
    String rawName=theClass.getRawName();
    TypeInfo refInfo=typeInfo.get(rawName);
    if (refInfo == null && shouldGenerateTypeInfo(theClass)) {
      refInfo=createTypeInfoFor(theClass);
    }
    if (refInfo != null && refInfo.getXmlValueProperty() == null) {
      throw JAXBException.invalidTypeForXmlValueField(propName);
    }
  }
}

Fixed version (ground truth):
private void validateXmlValueFieldOrProperty(JavaClass cls,Property property,JavaClass ptype,String propName){
  JavaClass parent=cls.getSuperclass();
  while (parent != null && !(parent.getQualifiedName().equals("String_Node_Str"))) {
    TypeInfo parentTypeInfo=typeInfo.get(parent.getQualifiedName());
    if (parentTypeInfo != null || (parentTypeInfo == null && shouldGenerateTypeInfo(parent))) {
      throw JAXBException.propertyOrFieldCannotBeXmlValue(propName);
    }
    parent=parent.getSuperclass();
  }
  JavaClass theClass;
  if (isCollectionType(property)) {
    theClass=property.getGenericType();
  }
 else   if (ptype.isArray()) {
    theClass=ptype.getComponentType();
  }
 else {
    theClass=ptype;
  }
  QName schemaQName=getSchemaTypeOrNullFor(theClass);
  if (schemaQName == null) {
    String rawName=theClass.getRawName();
    TypeInfo refInfo=typeInfo.get(rawName);
    if (refInfo != null) {
      if (!refInfo.isPostBuilt()) {
        postBuildTypeInfo(new JavaClass[]{theClass});
      }
    }
 else     if (shouldGenerateTypeInfo(theClass)) {
      JavaClass[] jClasses=new JavaClass[]{theClass};
      preBuildTypeInfo(jClasses);
      postBuildTypeInfo(jClasses);
      refInfo=typeInfo.get(theClass.getQualifiedName());
    }
    if (refInfo != null && refInfo.getXmlValueProperty() == null) {
      throw JAXBException.invalidTypeForXmlValueField(propName);
    }
  }
}
Program: 67308
Project: 67308
Buggy source:
public void addEnumTypeInfo(JavaClass javaClass,EnumTypeInfo info){
  if (javaClass == null) {
    return;
  }
  info.setClassName(javaClass.getQualifiedName());
  Class restrictionClass=String.class;
  if (helper.isAnnotationPresent(javaClass,XmlEnum.class)) {
    XmlEnum xmlEnum=(XmlEnum)helper.getAnnotation(javaClass,XmlEnum.class);
    restrictionClass=xmlEnum.value();
  }
  QName restrictionBase=getSchemaTypeFor(helper.getJavaClass(restrictionClass));
  info.setRestrictionBase(restrictionBase);
  typeInfoClasses.add(javaClass);
  typeInfo.put(javaClass.getQualifiedName(),info);
  for (Iterator<JavaField> fieldIt=javaClass.getDeclaredFields().iterator(); fieldIt.hasNext(); ) {
    JavaField field=fieldIt.next();
    if (field.isEnumConstant()) {
      String fieldValue=field.getName();
      if (helper.isAnnotationPresent(field,XmlEnumValue.class)) {
        XmlEnumValue xmlEnumValue=(XmlEnumValue)helper.getAnnotation(field,XmlEnumValue.class);
        fieldValue=xmlEnumValue.value();
      }
      info.addObjectToFieldValuePair(field.getName(),fieldValue);
    }
  }
}

Fixed version (ground truth):
public void addEnumTypeInfo(JavaClass javaClass,EnumTypeInfo info){
  if (javaClass == null) {
    return;
  }
  info.setClassName(javaClass.getQualifiedName());
  Class restrictionClass=String.class;
  if (helper.isAnnotationPresent(javaClass,XmlEnum.class)) {
    XmlEnum xmlEnum=(XmlEnum)helper.getAnnotation(javaClass,XmlEnum.class);
    restrictionClass=xmlEnum.value();
  }
  QName restrictionBase=getSchemaTypeFor(helper.getJavaClass(restrictionClass));
  info.setRestrictionBase(restrictionBase);
  for (Iterator<JavaField> fieldIt=javaClass.getDeclaredFields().iterator(); fieldIt.hasNext(); ) {
    JavaField field=fieldIt.next();
    if (field.isEnumConstant()) {
      String fieldValue=field.getName();
      if (helper.isAnnotationPresent(field,XmlEnumValue.class)) {
        XmlEnumValue xmlEnumValue=(XmlEnumValue)helper.getAnnotation(field,XmlEnumValue.class);
        fieldValue=xmlEnumValue.value();
      }
      info.addObjectToFieldValuePair(field.getName(),fieldValue);
    }
  }
}
Program: 67310
Project: 67310
Buggy source:
private Schema getSchemaForNamespace(String namespace){
  if (schemaForNamespace == null) {
    schemaForNamespace=new HashMap<String,Schema>();
  }
  Schema schema=schemaForNamespace.get(namespace);
  if (schema == null) {
    NamespaceInfo namespaceInfo=getNamespaceInfoForNamespace(namespace);
    schema=new Schema();
    schema.setName("String_Node_Str" + schemaCount + "String_Node_Str");
    if (namespaceInfo != null) {
      if (namespaceInfo.getLocation() != null) {
        return null;
      }
      java.util.Vector namespaces=namespaceInfo.getNamespaceResolver().getNamespaces();
      for (int i=0; i < namespaces.size(); i++) {
        Namespace nextNamespace=(Namespace)namespaces.get(i);
        schema.getNamespaceResolver().put(nextNamespace.getPrefix(),nextNamespace.getNamespaceURI());
      }
    }
    schemaCount++;
    if (!namespace.equals("String_Node_Str")) {
      schema.setTargetNamespace(namespace);
      String prefix=null;
      if (namespaceInfo != null) {
        prefix=namespaceInfo.getNamespaceResolver().resolveNamespaceURI(namespace);
      }
      if (prefix == null) {
        prefix=schema.getNamespaceResolver().generatePrefix();
      }
      schema.getNamespaceResolver().put(prefix,namespace);
    }
    if (namespaceInfo != null) {
      schema.setAttributeFormDefault(namespaceInfo.isAttributeFormQualified());
      schema.setElementFormDefault(namespaceInfo.isElementFormQualified());
    }
    schemaForNamespace.put(namespace,schema);
  }
  return schema;
}

Fixed version (ground truth):
private Schema getSchemaForNamespace(String namespace){
  if (schemaForNamespace == null) {
    schemaForNamespace=new HashMap<String,Schema>();
  }
  Schema schema=schemaForNamespace.get(namespace);
  if (schema == null) {
    NamespaceInfo namespaceInfo=getNamespaceInfoForNamespace(namespace);
    schema=new Schema();
    schema.setName("String_Node_Str" + schemaCount + "String_Node_Str");
    if (namespaceInfo != null) {
      if (namespaceInfo.getLocation() != null && !namespaceInfo.getLocation().equals("String_Node_Str")) {
        return null;
      }
      java.util.Vector namespaces=namespaceInfo.getNamespaceResolver().getNamespaces();
      for (int i=0; i < namespaces.size(); i++) {
        Namespace nextNamespace=(Namespace)namespaces.get(i);
        schema.getNamespaceResolver().put(nextNamespace.getPrefix(),nextNamespace.getNamespaceURI());
      }
    }
    schemaCount++;
    if (!namespace.equals("String_Node_Str")) {
      schema.setTargetNamespace(namespace);
      String prefix=null;
      if (namespaceInfo != null) {
        prefix=namespaceInfo.getNamespaceResolver().resolveNamespaceURI(namespace);
      }
      if (prefix == null) {
        prefix=schema.getNamespaceResolver().generatePrefix();
      }
      schema.getNamespaceResolver().put(prefix,namespace);
    }
    if (namespaceInfo != null) {
      schema.setAttributeFormDefault(namespaceInfo.isAttributeFormQualified());
      schema.setElementFormDefault(namespaceInfo.isElementFormQualified());
    }
    schemaForNamespace.put(namespace,schema);
  }
  return schema;
}
Program: 67314
Project: 67314
Buggy source:
private DatabaseMapping buildXMLDirectMapping(String mappingUri){
  XMLDirectMapping mapping=new XMLDirectMapping();
  mapping.setAttributeName(getName());
  String xpath=getQualifiedXPath(mappingUri,true);
  mapping.setXPath(xpath);
  if (getXsdType() != null) {
    ((XMLField)mapping.getField()).setSchemaType(getXsdType());
  }
  if (getType().getInstanceClass() != null) {
    if (shouldAddInstanceClassConverter()) {
      InstanceClassConverter converter=new InstanceClassConverter();
      converter.setCustomClass(getType().getInstanceClass());
      mapping.setConverter(converter);
    }
  }
  if (nullable) {
    setIsSetNillablePolicyOnMapping(mapping,propertyName);
  }
 else {
    setIsSetOptionalPolicyOnMapping(mapping,propertyName);
  }
  return mapping;
}

Fixed version (ground truth):
private DatabaseMapping buildXMLDirectMapping(String mappingUri){
  XMLDirectMapping mapping=new XMLDirectMapping();
  mapping.setAttributeName(getName());
  String xpath=getQualifiedXPath(mappingUri,true);
  mapping.setXPath(xpath);
  if (getXsdType() != null) {
    ((XMLField)mapping.getField()).setSchemaType(getXsdType());
  }
  if (getType().getInstanceClass() != null) {
    if (shouldAddInstanceClassConverter()) {
      InstanceClassConverter converter=new InstanceClassConverter();
      converter.setCustomClass(getType().getInstanceClass());
      mapping.setConverter(converter);
    }
  }
  if (nullable) {
    setIsSetNillablePolicyOnMapping(mapping,propertyName);
  }
 else {
    setIsSetOptionalPolicyOnMapping(mapping,propertyName);
  }
  mapping.getNullPolicy().setNullRepresentedByEmptyNode(true);
  return mapping;
}
Program: 67316
Project: 67316
Buggy source:
protected void updateNamespaces(QName qname,MarshalRecord marshalRecord,XMLField xmlField){
  if (qname != null) {
    if (xmlField != null) {
      if (xmlField.isTypedTextField()) {
        if (xmlField.getSchemaType() == null) {
          if (qname.equals(XMLConstants.STRING_QNAME)) {
            return;
          }
        }
 else {
          if (xmlField.isSchemaType(qname)) {
            return;
          }
        }
      }
 else {
        return;
      }
    }
    String prefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if ((prefix == null) || prefix.equals("String_Node_Str")) {
      if (XMLConstants.SCHEMA_URL.equals(qname.getNamespaceURI())) {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_PREFIX);
      }
 else {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix();
      }
      marshalRecord.attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + prefix,qname.getNamespaceURI());
    }
    String typeValue=prefix + "String_Node_Str" + qname.getLocalPart();
    addTypeAttribute(marshalRecord,typeValue);
  }
}

Fixed version (ground truth):
protected void updateNamespaces(QName qname,MarshalRecord marshalRecord,XMLField xmlField){
  if (qname != null) {
    if (xmlField != null) {
      if (xmlField.isTypedTextField()) {
        if (xmlField.getSchemaType() == null) {
          if (qname.equals(XMLConstants.STRING_QNAME)) {
            return;
          }
        }
 else {
          if (xmlField.isSchemaType(qname)) {
            return;
          }
        }
      }
 else {
        return;
      }
    }
    String prefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if ((prefix == null) || prefix.equals("String_Node_Str")) {
      if (XMLConstants.SCHEMA_URL.equals(qname.getNamespaceURI())) {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_PREFIX);
      }
 else {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix();
      }
      marshalRecord.attribute(XMLConstants.XMLNS_URL,prefix,XMLConstants.XMLNS + "String_Node_Str" + prefix,qname.getNamespaceURI());
    }
    String typeValue=prefix + "String_Node_Str" + qname.getLocalPart();
    addTypeAttribute(marshalRecord,typeValue);
  }
}
Program: 67317
Project: 67317
Buggy source:
protected void addTypeAttribute(MarshalRecord marshalRecord,String typeValue){
  String xsiPrefix=null;
  if (marshalRecord.getNamespaceResolver() != null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
  }
 else {
    xsiPrefix=XMLConstants.SCHEMA_INSTANCE_PREFIX;
    marshalRecord.attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + "String_Node_Str" + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeValue);
}

Fixed version (ground truth):
protected void addTypeAttribute(MarshalRecord marshalRecord,String typeValue){
  String xsiPrefix=null;
  if (marshalRecord.getNamespaceResolver() != null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
  }
 else {
    xsiPrefix=XMLConstants.SCHEMA_INSTANCE_PREFIX;
    marshalRecord.attribute(XMLConstants.XMLNS_URL,xsiPrefix,XMLConstants.XMLNS + "String_Node_Str" + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.attribute(XMLConstants.XMLNS_URL,xsiPrefix,XMLConstants.XMLNS + "String_Node_Str" + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + "String_Node_Str" + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeValue);
}
Program: 67319
Project: 67319
Buggy source:
private void marshalSimpleValue(XPathFragment xmlRootFragment,MarshalRecord marshalRecord,Object originalValue,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlRootFragment != null) {
    QName qname=((XMLRoot)originalValue).getSchemaType();
    value=getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
    Namespace generatedNamespace=setupFragment((XMLRoot)originalValue,xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  marshalRecord.characters((String)value);
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}

Fixed version (ground truth):
private void marshalSimpleValue(XPathFragment xmlRootFragment,MarshalRecord marshalRecord,Object originalValue,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlRootFragment != null) {
    QName qname=((XMLRoot)originalValue).getSchemaType();
    value=getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
    Namespace generatedNamespace=setupFragment((XMLRoot)originalValue,xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.attribute(XMLConstants.XMLNS_URL,generatedNamespace.getPrefix(),XMLConstants.XMLNS + "String_Node_Str" + generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  marshalRecord.characters((String)value);
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}
Program: 67320
Project: 67320
Buggy source:
private void marshalSimpleValue(XPathFragment xmlRootFragment,MarshalRecord marshalRecord,Object originalValue,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlRootFragment != null) {
    QName qname=((XMLRoot)originalValue).getSchemaType();
    value=getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
    Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  if (value instanceof String) {
    marshalRecord.characters((String)value);
  }
 else {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
  }
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}

Fixed version (ground truth):
private void marshalSimpleValue(XPathFragment xmlRootFragment,MarshalRecord marshalRecord,Object originalValue,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlRootFragment != null) {
    QName qname=((XMLRoot)originalValue).getSchemaType();
    value=getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
    Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.attribute(XMLConstants.XMLNS_URL,generatedNamespace.getPrefix(),XMLConstants.XMLNS + "String_Node_Str" + generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  if (value instanceof String) {
    marshalRecord.characters((String)value);
  }
 else {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
  }
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}
Program: 67321
Project: 67321
Buggy source:
protected void writeExtraNamespaces(List extraNamespaces,XMLRecord xmlRecord,AbstractSession session){
  if (extraNamespaces == null) {
    return;
  }
  for (int i=0; i < extraNamespaces.size(); i++) {
    Namespace next=(Namespace)extraNamespaces.get(i);
    ((MarshalRecord)xmlRecord).attribute(XMLConstants.XMLNS_URL,XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + next.getPrefix(),next.getNamespaceURI());
  }
}

Fixed version (ground truth):
protected void writeExtraNamespaces(List extraNamespaces,XMLRecord xmlRecord,AbstractSession session){
  if (extraNamespaces == null) {
    return;
  }
  for (int i=0; i < extraNamespaces.size(); i++) {
    Namespace next=(Namespace)extraNamespaces.get(i);
    ((MarshalRecord)xmlRecord).attribute(XMLConstants.XMLNS_URL,next.getPrefix(),XMLConstants.XMLNS + "String_Node_Str" + next.getPrefix(),next.getNamespaceURI());
  }
}