nus-yam/ex-repair huggingface dataset:
Program: 65387
Project: 65387
Buggy source:
/** 
 * INTERNAL:
 */
public void openStartElement(XPathFragment xPathFragment,NamespaceResolver namespaceResolver){
  this.addPositionalNodes(xPathFragment,namespaceResolver);
  try {
    if (isStartElementOpen) {
      writer.write('>');
    }
    if (!isLastEventText) {
      if (numberOfTabs > 0) {
        writer.write(Helper.cr());
      }
      for (int x=0; x < numberOfTabs; x++) {
        writeValue(tab());
      }
    }
    isStartElementOpen=true;
    writer.write('<');
    writer.write(getNameForFragment(xPathFragment));
    numberOfTabs++;
    isLastEventText=false;
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void openStartElement(XPathFragment xPathFragment,NamespaceResolver namespaceResolver){
  this.addPositionalNodes(xPathFragment,namespaceResolver);
  try {
    if (isStartElementOpen) {
      writer.write('>');
    }
    if (!isLastEventText) {
      if (numberOfTabs > 0) {
        writer.write(Helper.cr());
      }
      for (int x=0; x < numberOfTabs; x++) {
        writer.write(tab());
      }
    }
    isStartElementOpen=true;
    writer.write('<');
    writer.write(getNameForFragment(xPathFragment));
    numberOfTabs++;
    isLastEventText=false;
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65388
Project: 65388
Buggy source:
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    isLastEventText=false;
    numberOfTabs--;
    if (isStartElementOpen) {
      writer.write('/');
      writer.write('>');
      isStartElementOpen=false;
      complexType=true;
      return;
    }
    if (complexType) {
      writer.write(Helper.cr());
      for (int x=0; x < numberOfTabs; x++) {
        writeValue(tab());
      }
    }
 else {
      complexType=true;
    }
    super.endElement(namespaceURI,localName,qName);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    isLastEventText=false;
    numberOfTabs--;
    if (isStartElementOpen) {
      writer.write('/');
      writer.write('>');
      isStartElementOpen=false;
      complexType=true;
      return;
    }
    if (complexType) {
      writer.write(Helper.cr());
      for (int x=0; x < numberOfTabs; x++) {
        writer.write(tab());
      }
    }
 else {
      complexType=true;
    }
    super.endElement(namespaceURI,localName,qName);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65389
Project: 65389
Buggy source:
private String tab(){
  if (tab == null) {
    tab=getMarshaller().getIndentString();
  }
  return tab;
}

Fixed version (ground truth):
private String tab(){
  if (tab == null) {
    CharArrayWriter out=new CharArrayWriter();
    writeValue(getMarshaller().getIndentString(),false,out);
    out.close();
    tab=out.toString();
  }
  return tab;
}
Program: 65390
Project: 65390
Buggy source:
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  try {
    if (isStartElementOpen) {
      writer.write('>');
    }
    if (!isLastEventText) {
      writer.write(Helper.cr());
      for (int x=0; x < numberOfTabs; x++) {
        writeValue(tab());
      }
    }
    writer.write('<');
    writer.write(qName);
    numberOfTabs++;
    isStartElementOpen=true;
    isLastEventText=false;
    handleAttributes(atts);
    writePrefixMappings();
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  try {
    if (isStartElementOpen) {
      writer.write('>');
    }
    if (!isLastEventText) {
      writer.write(Helper.cr());
      for (int x=0; x < numberOfTabs; x++) {
        writer.write(tab());
      }
    }
    writer.write('<');
    writer.write(qName);
    numberOfTabs++;
    isStartElementOpen=true;
    isLastEventText=false;
    handleAttributes(atts);
    writePrefixMappings();
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65391
Project: 65391
Buggy source:
/** 
 * INTERNAL:
 */
public void element(XPathFragment frag){
  try {
    isLastEventText=false;
    if (isStartElementOpen) {
      writer.write('>');
      isStartElementOpen=false;
    }
    writer.write(Helper.cr());
    for (int x=0; x < numberOfTabs; x++) {
      writeValue(tab());
    }
    super.element(frag);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void element(XPathFragment frag){
  try {
    isLastEventText=false;
    if (isStartElementOpen) {
      writer.write('>');
      isStartElementOpen=false;
    }
    writer.write(Helper.cr());
    for (int x=0; x < numberOfTabs; x++) {
      writer.write(tab());
    }
    super.element(frag);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65392
Project: 65392
Buggy source:
/** 
 * INTERNAL:
 */
public void attribute(String namespaceURI,String localName,String qName,String value){
  try {
    outputStreamWrite(SPACE);
    outputStreamWrite(qName.getBytes(XMLConstants.DEFAULT_XML_ENCODING));
    outputStreamWrite((byte)'=');
    outputStreamWrite((byte)'"');
    writeValue(value,true,true);
    outputStreamWrite(CLOSE_ATTRIBUTE_VALUE);
  }
 catch (  UnsupportedEncodingException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void attribute(String namespaceURI,String localName,String qName,String value){
  try {
    outputStreamWrite(SPACE);
    outputStreamWrite(qName.getBytes(XMLConstants.DEFAULT_XML_ENCODING));
    outputStreamWrite((byte)'=');
    outputStreamWrite((byte)'"');
    writeValue(value,true,true,this.outputStream);
    outputStreamWrite(CLOSE_ATTRIBUTE_VALUE);
  }
 catch (  UnsupportedEncodingException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65394
Project: 65394
Buggy source:
protected void outputStreamWrite(byte aByte){
  if (bufferIndex == BUFFER_SIZE) {
    try {
      outputStream.write(buffer,0,BUFFER_SIZE);
      bufferIndex=0;
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
  }
  buffer[bufferIndex++]=aByte;
}

Fixed version (ground truth):
protected void outputStreamWrite(byte aByte,OutputStream os){
  if (os != this.outputStream) {
    try {
      os.write(aByte);
      return;
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
  }
  if (bufferIndex == BUFFER_SIZE) {
    try {
      os.write(buffer,0,BUFFER_SIZE);
      bufferIndex=0;
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
  }
  buffer[bufferIndex++]=aByte;
}
Program: 65395
Project: 65395
Buggy source:
/** 
 * INTERNAL:
 */
public void attribute(String namespaceURI,String localName,String qName,String value){
  try {
    writer.write(' ');
    writer.write(qName);
    writer.write('=');
    writer.write('\"');
    writeValue(value,true);
    writer.write('\"');
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void attribute(String namespaceURI,String localName,String qName,String value){
  try {
    writer.write(' ');
    writer.write(qName);
    writer.write('=');
    writer.write('\"');
    writeValue(value,true,this.writer);
    writer.write('\"');
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65396
Project: 65396
Buggy source:
/** 
 * INTERNAL:
 */
protected void writeValue(String value,boolean isAttribute){
  CharacterEscapeHandler escapeHandler=null;
  if (marshaller != null) {
    escapeHandler=marshaller.getCharacterEscapeHandler();
  }
  if (escapeHandler != null) {
    try {
      escapeHandler.escape(value.toCharArray(),0,value.length(),isAttribute,writer);
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
    return;
  }
  try {
    if (value.indexOf('"') > -1 || value.indexOf('&') > -1 || value.indexOf('<') > -1) {
      char[] chars=value.toCharArray();
      for (int x=0, charsSize=chars.length; x < charsSize; x++) {
        char character=chars[x];
switch (character) {
case '&':
{
            writer.write("String_Node_Str");
            break;
          }
case '<':
{
          writer.write("String_Node_Str");
          break;
        }
case '"':
{
        writer.write("String_Node_Str");
        break;
      }
default :
    writer.write(character);
}
}
}
 else {
writer.write(value);
}
}
 catch (IOException e) {
throw XMLMarshalException.marshalException(e);
}
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
protected void writeValue(String value,boolean isAttribute,Writer writer){
  CharacterEscapeHandler escapeHandler=null;
  if (marshaller != null) {
    escapeHandler=marshaller.getCharacterEscapeHandler();
  }
  if (escapeHandler != null) {
    try {
      escapeHandler.escape(value.toCharArray(),0,value.length(),isAttribute,writer);
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
    return;
  }
  try {
    if (value.indexOf('"') > -1 || value.indexOf('&') > -1 || value.indexOf('<') > -1) {
      char[] chars=value.toCharArray();
      for (int x=0, charsSize=chars.length; x < charsSize; x++) {
        char character=chars[x];
switch (character) {
case '&':
{
            writer.write("String_Node_Str");
            break;
          }
case '<':
{
          writer.write("String_Node_Str");
          break;
        }
case '"':
{
        writer.write("String_Node_Str");
        break;
      }
default :
    writer.write(character);
}
}
}
 else {
writer.write(value);
}
}
 catch (IOException e) {
throw XMLMarshalException.marshalException(e);
}
}
Program: 65397
Project: 65397
Buggy source:
public void testEmployeeSchemaGeneration() throws Exception {
  boolean exception=false;
  String msg=null;
  String src="String_Node_Str";
  String tmpdir=System.getenv("String_Node_Str");
  try {
    Class[] jClasses=new Class[]{Address.class,Employee.class,PhoneNumber.class,Department.class,MyTestType.class};
    Generator gen=new Generator(new JavaModelInputImpl(jClasses,new JavaModelImpl(Thread.currentThread().getContextClassLoader())));
    gen.generateSchemaFiles(tmpdir,null);
    SchemaFactory sFact=SchemaFactory.newInstance(XMLConstants.SCHEMA_URL);
    Schema theSchema=sFact.newSchema(new File(tmpdir + "String_Node_Str"));
    Validator validator=theSchema.newValidator();
    StreamSource ss=new StreamSource(new File(src));
    validator.validate(ss);
  }
 catch (  Exception ex) {
    exception=true;
    msg=ex.toString();
  }
  assertTrue("String_Node_Str" + msg,exception == false);
  DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance();
  builderFactory.setIgnoringElementContentWhitespace(true);
  builderFactory.setNamespaceAware(true);
  DocumentBuilder parser=builderFactory.newDocumentBuilder();
  InputStream stream=new FileInputStream(new File("String_Node_Str"));
  Document control=parser.parse(stream);
  stream=new FileInputStream(new File(tmpdir + "String_Node_Str"));
  Document test=parser.parse(stream);
  JAXBXMLComparer xmlComparer=new JAXBXMLComparer();
  assertTrue("String_Node_Str",xmlComparer.isSchemaEqual(control,test));
}

Fixed version (ground truth):
public void testEmployeeSchemaGeneration() throws Exception {
  boolean exception=false;
  String msg=null;
  String src="String_Node_Str";
  String tmpdir=System.getenv("String_Node_Str");
  if (tmpdir == null) {
    tmpdir=System.getProperty("String_Node_Str");
  }
  try {
    Class[] jClasses=new Class[]{Address.class,Employee.class,PhoneNumber.class,Department.class,MyTestType.class};
    Generator gen=new Generator(new JavaModelInputImpl(jClasses,new JavaModelImpl(Thread.currentThread().getContextClassLoader())));
    gen.generateSchemaFiles(tmpdir,null);
    SchemaFactory sFact=SchemaFactory.newInstance(XMLConstants.SCHEMA_URL);
    Schema theSchema=sFact.newSchema(new File(tmpdir + "String_Node_Str"));
    Validator validator=theSchema.newValidator();
    StreamSource ss=new StreamSource(new File(src));
    validator.validate(ss);
  }
 catch (  Exception ex) {
    exception=true;
    msg=ex.toString();
  }
  assertTrue("String_Node_Str" + msg,exception == false);
  DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance();
  builderFactory.setIgnoringElementContentWhitespace(true);
  builderFactory.setNamespaceAware(true);
  DocumentBuilder parser=builderFactory.newDocumentBuilder();
  InputStream stream=new FileInputStream(new File("String_Node_Str"));
  Document control=parser.parse(stream);
  stream=new FileInputStream(new File(tmpdir + "String_Node_Str"));
  Document test=parser.parse(stream);
  JAXBXMLComparer xmlComparer=new JAXBXMLComparer();
  assertTrue("String_Node_Str",xmlComparer.isSchemaEqual(control,test));
}
Program: 65401
Project: 65401
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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    Namespace generatedNamespace=setupFragment((XMLRoot)originalValue,xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(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){
  QName qname=null;
  if (xmlRootFragment != null) {
    qname=((XMLRoot)originalValue).getSchemaType();
    Namespace generatedNamespace=setupFragment((XMLRoot)originalValue,xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  marshalRecord.characters(qname,value,null,false);
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}
Program: 65403
Project: 65403
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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(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){
  QName qname=null;
  if (xmlRootFragment != null) {
    qname=((XMLRoot)originalValue).getSchemaType();
    Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  if (value instanceof org.w3c.dom.Node) {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
  }
 else {
    marshalRecord.characters(qname,value,null,false);
  }
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}
Program: 65404
Project: 65404
Buggy source:
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor referenceDescriptor=super.findReferenceDescriptor(xPathFragment,unmarshalRecord,atts,mapping,policy);
  if (referenceDescriptor == null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    QName qname=new QName(xPathFragment.getNamespaceURI(),xPathFragment.getLocalName());
    referenceDescriptor=xmlContext.getDescriptor(qname);
    if (referenceDescriptor != null && referenceDescriptor.isWrapper()) {
      referenceDescriptor=null;
    }
  }
  return referenceDescriptor;
}

Fixed version (ground truth):
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts,DatabaseMapping mapping,UnmarshalKeepAsElementPolicy policy){
  XMLDescriptor referenceDescriptor=super.findReferenceDescriptor(xPathFragment,unmarshalRecord,atts,mapping,policy);
  if (referenceDescriptor == null) {
    XMLContext xmlContext=unmarshalRecord.getUnmarshaller().getXMLContext();
    XPathQName xpathQName=new XPathQName(xPathFragment.getNamespaceURI(),xPathFragment.getLocalName(),unmarshalRecord.isNamespaceAware());
    referenceDescriptor=xmlContext.getDescriptor(xpathQName);
    if (referenceDescriptor != null && referenceDescriptor.isWrapper()) {
      referenceDescriptor=null;
    }
  }
  return referenceDescriptor;
}
Program: 65407
Project: 65407
Buggy source:
public void characters(char[] ch,int start,int length) throws SAXException {
  if (isProcessingCData) {
    cdata(new String(ch,start,length));
    return;
  }
  if (new String(ch).trim().length() == 0) {
    return;
  }
  super.characters(ch,start,length);
  isLastEventText=true;
  complexType=false;
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void characters(String value){
  super.characters(value);
  isLastEventText=true;
  complexType=false;
}
Program: 65408
Project: 65408
Buggy source:
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    isLastEventText=false;
    numberOfTabs--;
    if (isStartElementOpen) {
      writer.write('/');
      writer.write('>');
      isStartElementOpen=false;
      complexType=true;
      return;
    }
    if (complexType) {
      writer.write(Helper.cr());
      for (int x=0; x < numberOfTabs; x++) {
        writeValue(tab());
      }
    }
 else {
      complexType=true;
    }
    super.endElement(namespaceURI,localName,qName);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  XPathFragment xPathFragment=new XPathFragment(localName);
  xPathFragment.setNamespaceURI(namespaceURI);
  JSONFormattedWriterRecord.this.endElement(xPathFragment,namespaceResolver);
}
Program: 65409
Project: 65409
Buggy source:
WriterRecordContentHandler(){
  prefixMappings=new HashMap<String,String>();
}

Fixed version (ground truth):
WriterRecordContentHandler(){
}
Program: 65410
Project: 65410
Buggy source:
protected void writeComment(char[] chars,int start,int length){
  try {
    writer.write('<');
    writer.write('!');
    writer.write('-');
    writer.write('-');
    for (int x=start; x < length; x++) {
      writer.write(chars[x]);
    }
    writer.write('-');
    writer.write('-');
    writer.write('>');
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
protected void writeComment(char[] chars,int start,int length){
}
Program: 65411
Project: 65411
Buggy source:
public void characters(CharSequence characters) throws SAXException {
  if (isProcessingCData) {
    cdata(characters.toString());
    return;
  }
  if (isStartElementOpen) {
    try {
      writer.write('>');
      isStartElementOpen=false;
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
  }
  writeValue(characters.toString());
}

Fixed version (ground truth):
public void characters(CharSequence characters) throws SAXException {
  JSONWriterRecord.this.characters(characters.toString());
}
Program: 65412
Project: 65412
Buggy source:
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    if (isStartElementOpen) {
      writer.write('/');
      writer.write('>');
    }
 else {
      writer.write('<');
      writer.write('/');
      writer.write(qName);
      writer.write('>');
    }
    isStartElementOpen=false;
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  XPathFragment xPathFragment=new XPathFragment(localName);
  xPathFragment.setNamespaceURI(namespaceURI);
  JSONWriterRecord.this.endElement(xPathFragment,namespaceResolver);
}
Program: 65413
Project: 65413
Buggy source:
public void startPrefixMapping(String prefix,String uri) throws SAXException {
  String namespaceUri=getNamespaceResolver().resolveNamespacePrefix(prefix);
  if (namespaceUri == null || !namespaceUri.equals(uri)) {
    prefixMappings.put(prefix,uri);
  }
}

Fixed version (ground truth):
public void startPrefixMapping(String prefix,String uri) throws SAXException {
}
Program: 65414
Project: 65414
Buggy source:
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  try {
    if (isStartElementOpen) {
      writer.write('>');
    }
    writer.write('<');
    writer.write(qName);
    isStartElementOpen=true;
    handleAttributes(atts);
    writePrefixMappings();
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  XPathFragment xPathFragment=new XPathFragment(localName);
  xPathFragment.setNamespaceURI(namespaceURI);
  openStartElement(xPathFragment,namespaceResolver);
}
Program: 65415
Project: 65415
Buggy source:
protected void writeCharacters(char[] chars,int start,int length){
  try {
    for (int x=start; x < length; x++) {
      writer.write(chars[x]);
    }
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
protected void writeCharacters(char[] chars,int start,int length){
  try {
    characters(chars,start,length);
  }
 catch (  SAXException e) {
    throw XMLMarshalException.marshalException(e);
  }
}
Program: 65416
Project: 65416
Buggy source:
public void comment(char[] ch,int start,int length) throws SAXException {
  try {
    if (isStartElementOpen) {
      writer.write('>');
      isStartElementOpen=false;
    }
    writeComment(ch,start,length);
  }
 catch (  IOException e) {
    throw XMLMarshalException.marshalException(e);
  }
}

Fixed version (ground truth):
public void comment(char[] ch,int start,int length) throws SAXException {
}
Program: 65418
Project: 65418
Buggy source:
/** 
 * PUBLIC: Return the default root element name for the ClassDescriptor This value is stored in place of a table name This value is mandatory for all root objects
 * @param newDefaultRootElement the default root element to specify on this ClassDescriptor
 */
public void setDefaultRootElement(String newDefaultRootElement){
  if (setDefaultRootElementField(newDefaultRootElement)) {
    int index=getTableNames().indexOf(newDefaultRootElement);
    if (index == 0) {
      return;
    }
 else     if (index >= 0) {
      getTables().remove(index);
      getTables().add(0,new DatabaseTable(newDefaultRootElement));
    }
 else {
      getTables().add(0,new DatabaseTable(newDefaultRootElement));
    }
  }
}

Fixed version (ground truth):
/** 
 * PUBLIC: Return the default root element name for the ClassDescriptor This value is stored in place of a table name This value is mandatory for all root objects
 * @param newDefaultRootElement the default root element to specify on this ClassDescriptor
 */
public void setDefaultRootElement(String newDefaultRootElement){
  if (setDefaultRootElementField(newDefaultRootElement)) {
    int index=getTableNames().indexOf(newDefaultRootElement);
    if (index == 0) {
      return;
    }
    DatabaseTable databaseTable=new DatabaseTable();
    databaseTable.setUseDelimiters(false);
    databaseTable.setName(newDefaultRootElement);
    if (index >= 0) {
      getTables().remove(index);
      getTables().add(0,databaseTable);
    }
 else {
      getTables().add(0,databaseTable);
    }
  }
}
Program: 65420
Project: 65420
Buggy source:
@Override public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  if (XMLConstants.XOP_URL.equals(namespaceURI) && (INCLUDE_ELEMENT_NAME.equals(localName) || INCLUDE_ELEMENT_NAME.equals(qName))) {
    this.c_id=atts.getValue(XMLConstants.EMPTY_STRING,HREF_ATTRIBUTE_NAME);
  }
 else   if (c_id == null) {
    XMLReader xmlReader=record.getXMLReader();
    xmlReader.setContentHandler(record);
    xmlReader.setLexicalHandler(record);
    record.startElement(namespaceURI,localName,qName,atts);
  }
}

Fixed version (ground truth):
@Override public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  if (INCLUDE_ELEMENT_NAME.equals(localName) || INCLUDE_ELEMENT_NAME.equals(qName)) {
    if (record.isNamespaceAware()) {
      if (XMLConstants.XOP_URL.equals(namespaceURI)) {
        this.c_id=atts.getValue(XMLConstants.EMPTY_STRING,HREF_ATTRIBUTE_NAME);
      }
    }
 else {
      this.c_id=atts.getValue(XMLConstants.EMPTY_STRING,HREF_ATTRIBUTE_NAME);
    }
  }
 else   if (c_id == null) {
    XMLReader xmlReader=record.getXMLReader();
    xmlReader.setContentHandler(record);
    xmlReader.setLexicalHandler(record);
    record.startElement(namespaceURI,localName,qName,atts);
  }
}
Program: 65421
Project: 65421
Buggy source:
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlBinaryDataCollectionMapping.isReadOnly()) {
    return false;
  }
  Object collection=xmlBinaryDataCollectionMapping.getAttributeAccessor().getAttributeValueFromObject(object);
  if (null == collection) {
    AbstractNullPolicy wrapperNP=xmlBinaryDataCollectionMapping.getWrapperNullPolicy();
    if (wrapperNP != null && wrapperNP.getMarshalNullRepresentation().equals(XMLNullRepresentationType.XSI_NIL)) {
      marshalRecord.nilSimple(namespaceResolver);
      return true;
    }
 else {
      return false;
    }
  }
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(collection);
  if (!cp.hasNext(iterator)) {
    if (xmlBinaryDataCollectionMapping.getWrapperNullPolicy() != null) {
      XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      return false;
    }
  }
  while (cp.hasNext(iterator)) {
    Object objectValue=cp.next(iterator,session);
    marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,ObjectMarshalContext.getInstance());
  }
  return true;
}

Fixed version (ground truth):
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,AbstractSession session,NamespaceResolver namespaceResolver){
  if (xmlBinaryDataCollectionMapping.isReadOnly()) {
    return false;
  }
  Object collection=xmlBinaryDataCollectionMapping.getAttributeAccessor().getAttributeValueFromObject(object);
  if (null == collection) {
    AbstractNullPolicy wrapperNP=xmlBinaryDataCollectionMapping.getWrapperNullPolicy();
    if (wrapperNP != null && wrapperNP.getMarshalNullRepresentation().equals(XMLNullRepresentationType.XSI_NIL)) {
      marshalRecord.nilSimple(namespaceResolver);
      return true;
    }
 else {
      return false;
    }
  }
  ContainerPolicy cp=getContainerPolicy();
  Object iterator=cp.iteratorFor(collection);
  if (!cp.hasNext(iterator)) {
    if (xmlBinaryDataCollectionMapping.getWrapperNullPolicy() != null) {
      XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      return false;
    }
  }
  marshalRecord.startCollection();
  while (cp.hasNext(iterator)) {
    Object objectValue=cp.next(iterator,session);
    marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,ObjectMarshalContext.getInstance());
  }
  marshalRecord.endCollection();
  return true;
}
Program: 65424
Project: 65424
Buggy source:
@Test public void createGroupTypeTest(){
  XMLUnmarshaller unmarshaller=xrService.getXMLContext().createUnmarshaller();
  Object personType1=unmarshaller.unmarshal(new StringReader(PTYPE_INPUT_XML));
  Object personType2=unmarshaller.unmarshal(new StringReader(PTYPE_INPUT2_XML));
  Object personType3=unmarshaller.unmarshal(new StringReader(PTYPE_INPUT3_XML));
  Invocation invocation=new Invocation("String_Node_Str");
  invocation.setParameter("String_Node_Str","String_Node_Str");
  invocation.setParameter("String_Node_Str",personType1);
  invocation.setParameter("String_Node_Str",personType2);
  invocation.setParameter("String_Node_Str",personType3);
  Operation op=xrService.getOperation(invocation.getName());
  Object result=op.invoke(xrService,invocation);
  assertNotNull("String_Node_Str",result);
  Document doc=xmlPlatform.createDocument();
  XMLMarshaller marshaller=xrService.getXMLContext().createMarshaller();
  marshaller.marshal(result,doc);
  Document controlDoc=xmlParser.parse(new StringReader(NEW_PTABLE_OUTPUT2_XML));
  assertTrue("String_Node_Str" + documentToString(controlDoc) + "String_Node_Str"+ documentToString(doc),comparer.isNodeEqual(controlDoc,doc));
}

Fixed version (ground truth):
@Test public void createGroupTypeTest(){
  Invocation invocation=new Invocation("String_Node_Str");
  invocation.setParameter("String_Node_Str","String_Node_Str");
  Operation op=xrService.getOperation(invocation.getName());
  Object result=op.invoke(xrService,invocation);
  assertNotNull("String_Node_Str",result);
  Document doc=xmlPlatform.createDocument();
  XMLMarshaller marshaller=xrService.getXMLContext().createMarshaller();
  marshaller.marshal(result,doc);
  Document controlDoc=xmlParser.parse(new StringReader(NEW_ETABLE_OUTPUT2_XML));
  assertTrue("String_Node_Str" + documentToString(controlDoc) + "String_Node_Str"+ documentToString(doc),comparer.isNodeEqual(controlDoc,doc));
}
Program: 65426
Project: 65426
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE2_FUNC,ddlDebug);
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE_PROC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE2_FUNC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE_PROC,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE2_FUNC,ddlDebug);
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE_PROC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE2_FUNC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE_PROC,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE,ddlDebug);
    runDdl(conn,DROP_MYEMPOBJECT_TABLE,ddlDebug);
    runDdl(conn,DROP_MYEMPOBJECT,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE,ddlDebug);
  }
}
Program: 65429
Project: 65429
Buggy source:
/** 
 * Set this Unmarshaller's custom IDResolver.
 * @see IDResolver
 * @since 2.4
 */
public void setIDResolver(IDResolver idResolver){
  this.idResolver=idResolver;
}

Fixed version (ground truth):
/** 
 * Set this Unmarshaller's custom IDResolver.
 * @see IDResolver
 * @since 2.3.3
 */
public void setIDResolver(IDResolver idResolver){
  this.idResolver=idResolver;
}
Program: 65430
Project: 65430
Buggy source:
/** 
 * Return this Unmarshaller's custom IDResolver.
 * @see IDResolver
 * @since 2.4
 * @return the custom IDResolver, or null if one has not been specified.
 */
public IDResolver getIDResolver(){
  return idResolver;
}

Fixed version (ground truth):
/** 
 * Return this Unmarshaller's custom IDResolver.
 * @see IDResolver
 * @since 2.3.3
 * @return the custom IDResolver, or null if one has not been specified.
 */
public IDResolver getIDResolver(){
  return idResolver;
}
Program: 65432
Project: 65432
Buggy source:
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE2_FUNC,ddlDebug);
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE_PROC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE2_FUNC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE,ddlDebug);
  }
}

Fixed version (ground truth):
@AfterClass public static void tearDown(){
  if (ddlDrop) {
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE2_FUNC,ddlDebug);
    runDdl(conn,DROP_ADD_PERSONTYPE_TO_TABLE_PROC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE2_FUNC,ddlDebug);
    runDdl(conn,DROP_GET_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE_PROC,ddlDebug);
    runDdl(conn,DROP_GROUPTYPE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE_TABLE,ddlDebug);
    runDdl(conn,DROP_PERSONTYPE,ddlDebug);
  }
}
Program: 65435
Project: 65435
Buggy source:
public String getPackageName(){
  if (jClass.getPackage() != null) {
    return jClass.getPackage().getName();
  }
 else {
    String className=jClass.getCanonicalName();
    if (className != null) {
      int index=className.lastIndexOf("String_Node_Str");
      if (index > -1) {
        return className.substring(0,index);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public String getPackageName(){
  if (jClass.getPackage() != null) {
    return jClass.getPackage().getName();
  }
 else {
    Class nonInnerClass=jClass;
    Class enclosingClass=jClass.getEnclosingClass();
    while (enclosingClass != null) {
      nonInnerClass=enclosingClass;
      enclosingClass=nonInnerClass.getEnclosingClass();
    }
    String className=nonInnerClass.getCanonicalName();
    if (className != null) {
      int index=className.lastIndexOf("String_Node_Str");
      if (index > -1) {
        return className.substring(0,index);
      }
    }
  }
  return null;
}
Program: 65436
Project: 65436
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.length() == 0) {
      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 + XMLConstants.COLON + prefix,qname.getNamespaceURI());
    }
    String typeValue=prefix + XMLConstants.COLON + 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.length() == 0) {
      if (XMLConstants.SCHEMA_URL.equals(qname.getNamespaceURI())) {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_PREFIX);
      }
 else {
        prefix=marshalRecord.getNamespaceResolver().generatePrefix();
      }
      marshalRecord.namespaceDeclaration(prefix,qname.getNamespaceURI());
    }
    String typeValue=prefix + XMLConstants.COLON + qname.getLocalPart();
    addTypeAttribute(marshalRecord,typeValue);
  }
}
Program: 65437
Project: 65437
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,xsiPrefix,XMLConstants.XMLNS + XMLConstants.COLON + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.attribute(XMLConstants.XMLNS_URL,xsiPrefix,XMLConstants.XMLNS + XMLConstants.COLON + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + XMLConstants.COLON + 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.namespaceDeclaration(xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=marshalRecord.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.namespaceDeclaration(xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeValue);
}
Program: 65440
Project: 65440
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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    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 + XMLConstants.COLON + 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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    Namespace generatedNamespace=setupFragment((XMLRoot)originalValue,xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(generatedNamespace.getPrefix(),generatedNamespace.getNamespaceURI());
    }
    updateNamespaces(qname,marshalRecord,null);
  }
  marshalRecord.characters((String)value);
  if (xmlRootFragment != null) {
    marshalRecord.endElement(xmlRootFragment,namespaceResolver);
  }
}
Program: 65441
Project: 65441
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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    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 + XMLConstants.COLON + 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=marshalRecord.getValueToWrite(qname,value,(XMLConversionManager)session.getDatasourcePlatform().getConversionManager());
    Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
    getXPathNode().startElement(marshalRecord,xmlRootFragment,object,session,namespaceResolver,null,null);
    if (generatedNamespace != null) {
      marshalRecord.namespaceDeclaration(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: 65446
Project: 65446
Buggy source:
protected void addTypeAttribute(XMLDescriptor descriptor,MarshalRecord marshalRecord,String schemaContext){
  String typeValue=schemaContext.substring(1);
  String xsiPrefix=null;
  if (descriptor.getNamespaceResolver() != null) {
    xsiPrefix=descriptor.getNamespaceResolver().resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
  }
 else {
    xsiPrefix=XMLConstants.SCHEMA_INSTANCE_PREFIX;
    marshalRecord.attribute(XMLConstants.XMLNS_URL,xsiPrefix,XMLConstants.XMLNS + XMLConstants.COLON + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=descriptor.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.attribute(XMLConstants.XMLNS_URL,xsiPrefix,XMLConstants.XMLNS + XMLConstants.COLON + xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeValue);
}

Fixed version (ground truth):
protected void addTypeAttribute(XMLDescriptor descriptor,MarshalRecord marshalRecord,String schemaContext){
  String typeValue=schemaContext.substring(1);
  String xsiPrefix=null;
  if (descriptor.getNamespaceResolver() != null) {
    xsiPrefix=descriptor.getNamespaceResolver().resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
  }
 else {
    xsiPrefix=XMLConstants.SCHEMA_INSTANCE_PREFIX;
    marshalRecord.namespaceDeclaration(xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  if (xsiPrefix == null) {
    xsiPrefix=descriptor.getNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
    marshalRecord.namespaceDeclaration(xsiPrefix,XMLConstants.SCHEMA_INSTANCE_URL);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE,xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,typeValue);
}