Program: 67353
Project: 67353
Buggy source:
/** 
 * Adds a type attribute on an element, the value of the attribute is determined by performing a lookup in the SimpleTypeTranslator to find the Schema type for the value.
 * @param elements NodeList which will have a type attribute added to them
 * @param simpleTypeTranslator SimpleTypeTranslator to perform lookup in
 * @param value Object to base the lookup on
 * @param schemaInstancePrefix the prefix representing the schema instance namespace
 */
private void addTypeAttributes(NodeList elements,XMLField field,Object value,String schemaInstancePrefix){
  NamespaceResolver namespaceResolver=getNamespaceResolverForField(field);
  if (!field.isTypedTextField()) {
    return;
  }
  List values;
  if (value instanceof List) {
    values=(List)value;
  }
 else {
    values=new ArrayList();
    values.add(value);
  }
  int size=elements.getLength();
  int valuesSize=values.size();
  if (size != valuesSize) {
    return;
  }
  Node next=null;
  for (int i=0; i < size; i++) {
    next=elements.item(i);
    if (next.getNodeType() == Node.ELEMENT_NODE) {
      Class valueClass=values.get(i).getClass();
      if (valueClass != ClassConstants.STRING) {
        QName qname=field.getXMLType(valueClass);
        if (qname != null) {
          if (null == schemaInstancePrefix) {
            schemaInstancePrefix=namespaceResolver.generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
            ((Element)next).setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + schemaInstancePrefix,XMLConstants.SCHEMA_INSTANCE_URL);
          }
          String type;
          String prefix=this.resolveNamespacePrefixForURI(qname.getNamespaceURI(),namespaceResolver);
          if ((prefix == null) || (prefix.equals("String_Node_Str"))) {
            type=qname.getLocalPart();
            prefix=namespaceResolver.generatePrefix();
            ((Element)next).setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + prefix,qname.getNamespaceURI());
          }
          type=prefix + "String_Node_Str" + qname.getLocalPart();
          ((Element)next).setAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,schemaInstancePrefix + "String_Node_Str" + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,type);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds a type attribute on an element, the value of the attribute is determined by performing a lookup in the SimpleTypeTranslator to find the Schema type for the value.
 * @param elements NodeList which will have a type attribute added to them
 * @param simpleTypeTranslator SimpleTypeTranslator to perform lookup in
 * @param value Object to base the lookup on
 * @param schemaInstancePrefix the prefix representing the schema instance namespace
 */
private void addTypeAttributes(NodeList elements,XMLField field,Object value,String schemaInstancePrefix){
  NamespaceResolver namespaceResolver=getNamespaceResolverForField(field);
  if (!field.isTypedTextField()) {
    return;
  }
  List values;
  if (value instanceof List) {
    values=(List)value;
  }
 else {
    values=new ArrayList();
    values.add(value);
  }
  int size=elements.getLength();
  int valuesSize=values.size();
  if (size != valuesSize) {
    return;
  }
  Node next=null;
  for (int i=0; i < size; i++) {
    next=elements.item(i);
    if (next.getNodeType() == Node.ELEMENT_NODE) {
      Class valueClass=values.get(i).getClass();
      if (valueClass != ClassConstants.STRING) {
        QName qname=field.getXMLType(valueClass);
        if (qname != null) {
          if (null == schemaInstancePrefix) {
            schemaInstancePrefix=namespaceResolver.generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX);
            ((Element)next).setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + schemaInstancePrefix,XMLConstants.SCHEMA_INSTANCE_URL);
          }
          String type;
          String prefix=this.resolveNamespacePrefixForURI(qname.getNamespaceURI(),namespaceResolver);
          if ((prefix == null) || (prefix.equals("String_Node_Str"))) {
            type=qname.getLocalPart();
            if (qname.getNamespaceURI().equals(XMLConstants.SCHEMA_URL)) {
              prefix=namespaceResolver.generatePrefix(XMLConstants.SCHEMA_PREFIX);
            }
 else {
              prefix=namespaceResolver.generatePrefix();
            }
            ((Element)next).setAttributeNS(XMLConstants.XMLNS_URL,XMLConstants.XMLNS + "String_Node_Str" + prefix,qname.getNamespaceURI());
          }
          type=prefix + "String_Node_Str" + qname.getLocalPart();
          ((Element)next).setAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,schemaInstancePrefix + "String_Node_Str" + XMLConstants.SCHEMA_TYPE_ATTRIBUTE,type);
        }
      }
    }
  }
}