nus-yam/ex-repair huggingface dataset:
Program: 100603
Project: 100603
Buggy source:
/** 
 * Remove an integer from this set.
 * @param i integer to remove
 * @return true iff the value of this changes.
 */
public boolean remove(int i){
  if (densePart != null && densePart.get(i)) {
    densePart.clear(i);
    return true;
  }
 else   if (sparsePart.contains(i)) {
    sparsePart.remove(i);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Remove an integer from this set.
 * @param i integer to remove
 * @return true iff the value of this changes.
 */
public boolean remove(int i){
  if (densePart != null && densePart.get(i)) {
    densePart.clear(i);
    if (densePart.populationCount() == 0) {
      densePart=null;
    }
    return true;
  }
 else   if (sparsePart.contains(i)) {
    sparsePart.remove(i);
    return true;
  }
 else {
    return false;
  }
}
Program: 100605
Project: 100605
Buggy source:
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append("String_Node_Str");
  for (int i=0; i < getMaxNumber(); i++) {
    Object node=getNode(i);
    if (node != null) {
      result.append(i).append("String_Node_Str").append(node).append("String_Node_Str");
    }
  }
  result.append("String_Node_Str");
  for (int i=0; i < getMaxNumber(); i++) {
    Object node=getNode(i);
    if (node != null) {
      result.append(i).append("String_Node_Str");
      for (Iterator it=getSuccNodes(node); it.hasNext(); ) {
        Object s=it.next();
        result.append(getNumber(s)).append("String_Node_Str");
      }
      result.append("String_Node_Str");
    }
  }
  return result.toString();
}

Fixed version (ground truth):
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append("String_Node_Str");
  for (int i=0; i <= getMaxNumber(); i++) {
    Object node=getNode(i);
    if (node != null) {
      result.append(i).append("String_Node_Str").append(node).append("String_Node_Str");
    }
  }
  result.append("String_Node_Str");
  for (int i=0; i <= getMaxNumber(); i++) {
    Object node=getNode(i);
    if (node != null) {
      result.append(i).append("String_Node_Str");
      for (Iterator it=getSuccNodes(node); it.hasNext(); ) {
        Object s=it.next();
        result.append(getNumber(s)).append("String_Node_Str");
      }
      result.append("String_Node_Str");
    }
  }
  return result.toString();
}
Program: 100606
Project: 100606
Buggy source:
/** 
 * Process attributes
 * @param qName element name
 * @param atts input attributes
 * @param res attributes to write to
 */
private void processAttributes(final String qName,final Attributes atts,final AttributesImpl res){
  final int attsLen=atts.getLength();
  for (int i=0; i < attsLen; i++) {
    final QName attQName=new QName(atts.getURI(i),atts.getLocalName(i));
    final String origValue=atts.getValue(i);
    String attValue=origValue;
    if (ATTRIBUTE_NAME_CONREF.equals(attQName)) {
      attValue=replaceHREF(QName.valueOf(ATTRIBUTE_NAME_CONREF),atts).toString();
    }
 else     if (ATTRIBUTE_NAME_HREF.equals(attQName) || ATTRIBUTE_NAME_COPY_TO.equals(attQName)) {
      if (atts.getValue(ATTRIBUTE_NAME_SCOPE) == null || atts.getValue(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_LOCAL)) {
        attValue=replaceHREF(attQName,atts).toString();
      }
    }
 else     if (ATTRIBUTE_NAME_FORMAT.equals(attQName)) {
      final String format=atts.getValue(ATTRIBUTE_NAME_FORMAT);
      if (isFormatDita(format)) {
        attValue=ATTR_FORMAT_VALUE_DITA;
      }
    }
 else {
      attValue=getAttributeValue(qName,attQName,attValue);
    }
    XMLUtils.addOrSetAttribute(res,atts.getURI(i),atts.getLocalName(i),atts.getQName(i),atts.getType(i),attValue);
  }
}

Fixed version (ground truth):
/** 
 * Process attributes
 * @param qName element name
 * @param atts input attributes
 * @param res attributes to write to
 */
private void processAttributes(final String qName,final Attributes atts,final AttributesImpl res){
  final int attsLen=atts.getLength();
  for (int i=0; i < attsLen; i++) {
    final QName attQName=new QName(atts.getURI(i),atts.getLocalName(i));
    final String origValue=atts.getValue(i);
    String attValue=origValue;
    if (ATTRIBUTE_NAME_CONREF.equals(attQName.getLocalPart())) {
      attValue=replaceHREF(QName.valueOf(ATTRIBUTE_NAME_CONREF),atts).toString();
    }
 else     if (ATTRIBUTE_NAME_HREF.equals(attQName.getLocalPart()) || ATTRIBUTE_NAME_COPY_TO.equals(attQName.getLocalPart())) {
      if (atts.getValue(ATTRIBUTE_NAME_SCOPE) == null || atts.getValue(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_LOCAL)) {
        attValue=replaceHREF(attQName,atts).toString();
      }
    }
 else     if (ATTRIBUTE_NAME_FORMAT.equals(attQName.getLocalPart())) {
      final String format=atts.getValue(ATTRIBUTE_NAME_FORMAT);
      if (isFormatDita(format)) {
        attValue=ATTR_FORMAT_VALUE_DITA;
      }
    }
 else {
      attValue=getAttributeValue(qName,attQName,attValue);
    }
    XMLUtils.addOrSetAttribute(res,atts.getURI(i),atts.getLocalName(i),atts.getQName(i),atts.getType(i),attValue);
  }
}
Program: 100607
Project: 100607
Buggy source:
public void readProp(final Element elem){
  final String attAction=elem.getAttribute(ELEMENT_NAME_ACTION);
  Action action;
switch (attAction) {
case "String_Node_Str":
    action=Action.INCLUDE;
  break;
case "String_Node_Str":
action=Action.EXCLUDE;
break;
case "String_Node_Str":
action=Action.PASSTHROUGH;
break;
case "String_Node_Str":
action=readFlag(elem);
break;
default :
throw new IllegalArgumentException("String_Node_Str" + attAction);
}
if (action != null) {
final QName attName;
if (elem.getTagName().equals(ELEMENT_NAME_REVPROP)) {
attName=REV;
}
 else {
final String attValue=getValue(elem,ATTRIBUTE_NAME_ATT);
if (attValue != null) {
if (attValue.contains("String_Node_Str")) {
final String[] parts=attValue.split("String_Node_Str");
final String uri;
if (parts[0].equals(XML_NS_PREFIX)) {
uri=XML_NS_URI;
}
 else {
uri=elem.lookupNamespaceURI(parts[0]);
}
attName=new QName(uri,parts[1],parts[0]);
}
 else {
attName=QName.valueOf(attValue);
}
}
 else {
attName=null;
}
}
if (attName != null && attName.equals(REV) && !filterAttributes.isEmpty() && !filterAttributes.contains(REV)) {
logger.warn(MessageUtils.getMessage("String_Node_Str").toString());
return;
}
final String attValue=getValue(elem,ATTRIBUTE_NAME_VAL);
final FilterKey key=attName != null ? new FilterKey(attName,attValue) : DEFAULT;
insertAction(action,key);
}
}

Fixed version (ground truth):
public void readProp(final Element elem){
  final String attAction=elem.getAttribute(ELEMENT_NAME_ACTION);
  Action action;
switch (attAction) {
case "String_Node_Str":
    action=Action.INCLUDE;
  break;
case "String_Node_Str":
action=Action.EXCLUDE;
break;
case "String_Node_Str":
action=Action.PASSTHROUGH;
break;
case "String_Node_Str":
action=readFlag(elem);
break;
default :
throw new IllegalArgumentException("String_Node_Str" + attAction);
}
if (action != null) {
final QName attName;
if (elem.getTagName().equals(ELEMENT_NAME_REVPROP)) {
attName=REV;
}
 else {
final String attValue=getValue(elem,ATTRIBUTE_NAME_ATT);
if (attValue != null) {
if (attValue.contains("String_Node_Str")) {
final String[] parts=attValue.split("String_Node_Str");
final String uri;
if (parts[0].equals(XML_NS_PREFIX)) {
uri=XML_NS_URI;
}
 else {
uri=elem.lookupNamespaceURI(parts[0]);
}
attName=new QName(uri,parts[1],parts[0]);
}
 else {
attName=QName.valueOf(attValue);
}
}
 else {
attName=null;
}
if (attName != null && attName.equals(REV) && !filterAttributes.isEmpty() && !filterAttributes.contains(REV)) {
logger.warn(MessageUtils.getMessage("String_Node_Str").toString());
return;
}
}
final String attValue=getValue(elem,ATTRIBUTE_NAME_VAL);
final FilterKey key=attName != null ? new FilterKey(attName,attValue) : DEFAULT;
insertAction(action,key);
}
}
Program: 100608
Project: 100608
Buggy source:
/** 
 * Get the first topic id from the given dita file.
 * @param absolutePathToFile The absolute path to a dita file.
 * @return The first topic id from the given dita file if success, otherwise{@code null} string is returned.
 */
String getFirstTopicId(final String absolutePathToFile){
}

Fixed version (ground truth):
/** 
 * Get the first topic id from the given dita file.
 * @param ditaTopicFile a dita file.
 * @return The first topic id from the given dita file if success, otherwise{@code null} string is returned.
 */
String getFirstTopicId(final File ditaTopicFile){
}
Program: 100611
Project: 100611
Buggy source:
/** 
 * Checks if the closest DITA ancestor <foreign> or <unknown>
 * @param classes stack of class attributes for open elements
 * @return true if closest DITA ancestor is <foreign> or <unknown>, otherwise false
 */
public static boolean nonDitaContext(final Deque<DitaClass> classes){
  final Iterator<DitaClass> it=classes.iterator();
  it.next();
  while (it.hasNext()) {
    final DitaClass cls=it.next();
    if (cls != null && cls.isValid() && (TOPIC_FOREIGN.matches(cls) || TOPIC_UNKNOWN.matches(cls))) {
      return true;
    }
 else     if (cls != null && cls.isValid()) {
      return false;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks if the closest DITA ancestor   {@code <foreign>} or {@code <unknown>}
 * @param classes stack of class attributes for open elements
 * @return true if closest DITA ancestor is {@code <foreign>} or {@code <unknown>}, otherwise false
 */
public static boolean nonDitaContext(final Deque<DitaClass> classes){
  final Iterator<DitaClass> it=classes.iterator();
  it.next();
  while (it.hasNext()) {
    final DitaClass cls=it.next();
    if (cls != null && cls.isValid() && (TOPIC_FOREIGN.matches(cls) || TOPIC_UNKNOWN.matches(cls))) {
      return true;
    }
 else     if (cls != null && cls.isValid()) {
      return false;
    }
  }
  return false;
}
Program: 100612
Project: 100612
Buggy source:
/** 
 * Determines whether the parent directory contains the child element (a file or directory)
 * @param directory the file to consider as the parent
 * @param child the file to consider as the child
 * @return true is the candidate leaf is under by the specified composite, otherwise false
 * @throws IOException
 */
public static boolean directoryContains(final File directory,final File child){
  final File d=new File(normalize(directory.getAbsolutePath()));
  final File c=new File(normalize(child.getAbsolutePath()));
  if (d.equals(c)) {
    return false;
  }
 else {
    return c.getPath().startsWith(d.getPath());
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the parent directory contains the child element (a file or directory)
 * @param directory the file to consider as the parent
 * @param child the file to consider as the child
 * @return true is the candidate leaf is under by the specified composite, otherwise false
 */
public static boolean directoryContains(final File directory,final File child){
  final File d=new File(normalize(directory.getAbsolutePath()));
  final File c=new File(normalize(child.getAbsolutePath()));
  if (d.equals(c)) {
    return false;
  }
 else {
    return c.getPath().startsWith(d.getPath());
  }
}
Program: 100613
Project: 100613
Buggy source:
/** 
 * Determines whether the parent directory contains the child element (a file or directory)
 * @param directory the file to consider as the parent
 * @param child the file to consider as the child
 * @return true is the candidate leaf is under by the specified composite, otherwise false
 * @throws IOException
 */
public static boolean directoryContains(final URI directory,final URI child){
  final String d=directory.normalize().toString();
  final String c=child.normalize().toString();
  if (d.equals(c)) {
    return false;
  }
 else {
    return c.startsWith(d);
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the parent directory contains the child element (a file or directory)
 * @param directory the file to consider as the parent
 * @param child the file to consider as the child
 * @return true is the candidate leaf is under by the specified composite, otherwise false
 */
public static boolean directoryContains(final URI directory,final URI child){
  final String d=directory.normalize().toString();
  final String c=child.normalize().toString();
  if (d.equals(c)) {
    return false;
  }
 else {
    return c.startsWith(d);
  }
}
Program: 100614
Project: 100614
Buggy source:
/** 
 * Write namepace prefix.
 * @param prefix namespace prefix
 * @param uri namespace URI
 * @throws SAXException if processing the event failed
 * @throws IllegalStateException if start element is not open
 * @throws IllegalArgumentException if prefix is already bound
 */
public void writeNamespace(final String prefix,final String uri){
  if (!openStartElement) {
    throw new IllegalStateException("String_Node_Str");
  }
  final QName qName=elementStack.getFirst();
  for (  final NamespaceMapping p : qName.mappings) {
    if (p.prefix.equals(prefix) && p.uri.equals(uri)) {
      return;
    }
 else     if (p.prefix.equals(prefix)) {
      throw new IllegalArgumentException("String_Node_Str" + prefix + "String_Node_Str"+ uri);
    }
  }
  qName.mappings.add(new NamespaceMapping(prefix,uri,true));
}

Fixed version (ground truth):
/** 
 * Write namepace prefix.
 * @param prefix namespace prefix
 * @param uri namespace URI
 * @throws IllegalStateException if start element is not open
 * @throws IllegalArgumentException if prefix is already bound
 */
public void writeNamespace(final String prefix,final String uri){
  if (!openStartElement) {
    throw new IllegalStateException("String_Node_Str");
  }
  final QName qName=elementStack.getFirst();
  for (  final NamespaceMapping p : qName.mappings) {
    if (p.prefix.equals(prefix) && p.uri.equals(uri)) {
      return;
    }
 else     if (p.prefix.equals(prefix)) {
      throw new IllegalArgumentException("String_Node_Str" + prefix + "String_Node_Str"+ uri);
    }
  }
  qName.mappings.add(new NamespaceMapping(prefix,uri,true));
}
Program: 100615
Project: 100615
Buggy source:
/** 
 * Write attribute
 * @param uri namespace URI
 * @param qName attribute name
 * @param value attribute value
 * @throws SAXException if processing the event failed
 * @throws IllegalStateException if start element is not open
 */
public void writeAttribute(final String uri,final String qName,final String value){
  if (!openStartElement) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (openAttributes == null) {
    openAttributes=new AttributesImpl();
  }
  final QName att=new QName(uri,qName);
  addNamespace(uri,att.prefix,elementStack.getFirst());
  openAttributes.addAttribute(uri,att.localName,qName,"String_Node_Str",value);
}

Fixed version (ground truth):
/** 
 * Write attribute
 * @param uri namespace URI
 * @param qName attribute name
 * @param value attribute value
 * @throws IllegalStateException if start element is not open
 */
public void writeAttribute(final String uri,final String qName,final String value){
  if (!openStartElement) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (openAttributes == null) {
    openAttributes=new AttributesImpl();
  }
  final QName att=new QName(uri,qName);
  addNamespace(uri,att.prefix,elementStack.getFirst());
  openAttributes.addAttribute(uri,att.localName,qName,"String_Node_Str",value);
}
Program: 100616
Project: 100616
Buggy source:
/** 
 * List child elements elements.
 * @param elem root element
 * @param deep {@code true} to read descendants, {@code false} to read only direct children
 * @raturn list of matching elements
 */
public static List<Element> getChildElements(final Element elem,final boolean deep){
  final NodeList children=deep ? elem.getElementsByTagName("String_Node_Str") : elem.getChildNodes();
  final List<Element> res=new ArrayList<>(children.getLength());
  for (int i=0; i < children.getLength(); i++) {
    final Node child=children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      res.add((Element)child);
    }
  }
  return res;
}

Fixed version (ground truth):
/** 
 * List child elements elements.
 * @param elem root element
 * @param deep {@code true} to read descendants, {@code false} to read only direct children
 * @return list of matching elements
 */
public static List<Element> getChildElements(final Element elem,final boolean deep){
  final NodeList children=deep ? elem.getElementsByTagName("String_Node_Str") : elem.getChildNodes();
  final List<Element> res=new ArrayList<>(children.getLength());
  for (int i=0; i < children.getLength(); i++) {
    final Node child=children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      res.add((Element)child);
    }
  }
  return res;
}
Program: 100617
Project: 100617
Buggy source:
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=XMLUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=XMLUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final RuntimeException e) {
    throw e;
  }
catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 100619
Project: 100619
Buggy source:
@Override public void endDocument() throws SAXException {
  try {
    for (    final FileInfo f : job.getFileInfo()) {
      if (f.isTarget) {
        String element=f.file.getPath();
        if (!dirPath.equals(tempdir)) {
          element=FileUtils.getRelativeUnixPath(new File(dirPath,"String_Node_Str").getAbsolutePath(),new File(tempdir,element).getAbsolutePath());
        }
        if (!util.isVisited(toURI(element))) {
          util.visit(toURI(element));
          if (!f.isResourceOnly) {
            final File file=new File(dirPath,element);
            if (file.exists()) {
              topicParser.parse(element,dirPath);
            }
 else {
              final String fileName=file.getAbsolutePath();
              logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",fileName).toString());
            }
          }
        }
      }
    }
  }
 catch (  final Exception e) {
    logger.error(e.getMessage(),e);
  }
  getContentHandler().endDocument();
}

Fixed version (ground truth):
@Override public void endDocument() throws SAXException {
  try {
    for (    final FileInfo f : job.getFileInfo()) {
      if (f.isTarget) {
        String element=f.file.getPath();
        if (!dirPath.equals(tempdir)) {
          element=FileUtils.getRelativeUnixPath(new File(dirPath,"String_Node_Str").getAbsolutePath(),new File(tempdir,element).getAbsolutePath());
        }
        final URI abs=job.tempDirURI.resolve(f.uri);
        if (!util.isVisited(abs)) {
          util.visit(abs);
          if (!f.isResourceOnly) {
            final File file=new File(dirPath,element);
            if (file.exists()) {
              topicParser.parse(element,dirPath);
            }
 else {
              final String fileName=file.getAbsolutePath();
              logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",fileName).toString());
            }
          }
        }
      }
    }
  }
 catch (  final RuntimeException e) {
    throw e;
  }
catch (  final Exception e) {
    logger.error(e.getMessage(),e);
  }
  getContentHandler().endDocument();
}
Program: 100620
Project: 100620
Buggy source:
/** 
 * Parse the file to update id.
 * @param filename relative topic system path, may contain a fragment part
 * @param dir topic directory system path
 */
public void parse(final String filename,final File dir){
  filePath=stripFragment(filename);
  dirPath=dir;
  try {
    final File f=new File(dir,filePath);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(f.getAbsolutePath(),logger));
    logger.info("String_Node_Str" + f.getAbsolutePath());
    reader.parse(f.toURI().toString());
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + filename + "String_Node_Str"+ e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Parse the file to update id.
 * @param filename relative topic system path, may contain a fragment part
 * @param dir topic directory system path
 */
public void parse(final String filename,final File dir){
  filePath=stripFragment(filename);
  dirPath=dir;
  try {
    final File f=new File(dir,filePath);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(f.getAbsolutePath(),logger));
    logger.info("String_Node_Str" + f.getAbsolutePath());
    reader.parse(f.toURI().toString());
  }
 catch (  final RuntimeException e) {
    throw e;
  }
catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + filename + "String_Node_Str"+ e.getMessage(),e);
  }
}
Program: 100622
Project: 100622
Buggy source:
/** 
 * Default Constructor.
 * @param util merge utility
 */
public MergeTopicParser(final MergeUtils util){
  this.util=util;
  try {
    reader=XMLUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Default Constructor.
 * @param util merge utility
 */
public MergeTopicParser(final MergeUtils util){
  this.util=util;
  try {
    reader=XMLUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  }
 catch (  final RuntimeException e) {
    throw e;
  }
catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 100623
Project: 100623
Buggy source:
/** 
 * Get copy-to map based on map processing.
 * @return target to source map of URIs relative to temporary directory
 */
private Map<URI,URI> getCopyToMap(){
  final Map<URI,URI> copyToMap=new HashMap<>();
  if (forceUnique) {
    copyToMap.putAll(forceUniqueFilter.copyToMap);
  }
  for (  final Map.Entry<URI,URI> e : reader.getCopyToMap().entrySet()) {
    final URI target=job.tempDir.toURI().relativize(e.getKey());
    final URI source=job.tempDir.toURI().relativize(e.getValue());
    if (job.getFileInfo(target) != null) {
      continue;
    }
    copyToMap.put(target,source);
  }
  return copyToMap;
}

Fixed version (ground truth):
/** 
 * Get copy-to map based on map processing.
 * @return target to source map of URIs relative to temporary directory
 */
private Map<URI,URI> getCopyToMap(){
  final Map<URI,URI> copyToMap=new HashMap<>();
  if (forceUnique) {
    copyToMap.putAll(forceUniqueFilter.copyToMap);
  }
  for (  final Map.Entry<URI,URI> e : reader.getCopyToMap().entrySet()) {
    final URI target=job.tempDir.toURI().relativize(e.getKey());
    final URI source=job.tempDir.toURI().relativize(e.getValue());
    final FileInfo fileInfo=job.getFileInfo(target);
    if (fileInfo != null && fileInfo.src != null) {
      continue;
    }
    copyToMap.put(target,source);
  }
  return copyToMap;
}
Program: 100624
Project: 100624
Buggy source:
/** 
 * Sort term list extracted from dita files base on Locale.
 */
public void sort(){
  final int termListSize=termList.size();
  if (IndexTerm.getTermLocale() == null || IndexTerm.getTermLocale().getLanguage().trim().length() == 0) {
    IndexTerm.setTermLocale(new Locale(LANGUAGE_EN,COUNTRY_US));
  }
  for (  final IndexTerm term : termList) {
    term.sortSubTerms();
  }
  Collections.sort(termList);
}

Fixed version (ground truth):
/** 
 * Sort term list extracted from dita files base on Locale.
 */
public void sort(){
  if (IndexTerm.getTermLocale() == null || IndexTerm.getTermLocale().getLanguage().trim().length() == 0) {
    IndexTerm.setTermLocale(new Locale(LANGUAGE_EN,COUNTRY_US));
  }
  for (  final IndexTerm term : termList) {
    term.sortSubTerms();
  }
  Collections.sort(termList);
}
Program: 100625
Project: 100625
Buggy source:
private void initialize() throws BuildException {
  if (tempDir == null) {
    tempDir=new File(this.getProject().getProperty(ANT_TEMP_DIR)).getAbsoluteFile();
  }
  if (tempDir == null) {
    throw new BuildException("String_Node_Str");
  }
  if (modules.isEmpty()) {
    throw new BuildException("String_Node_Str");
  }
  if (attrs.get(ANT_INVOKER_PARAM_BASEDIR) == null) {
    attrs.put(ANT_INVOKER_PARAM_BASEDIR,getProject().getBaseDir().getAbsolutePath());
  }
  for (  final Param p : pipelineParams) {
    if (!p.isValid()) {
      throw new BuildException("String_Node_Str");
    }
    final String ifProperty=p.getIf();
    final String unlessProperty=p.getUnless();
    if ((ifProperty == null || getProject().getProperties().containsKey(ifProperty)) && (unlessProperty == null || !getProject().getProperties().containsKey(unlessProperty))) {
      attrs.put(p.getName(),p.getValue());
    }
  }
}

Fixed version (ground truth):
private void initialize() throws BuildException {
  if (tempDir == null) {
    tempDir=new File(this.getProject().getProperty(ANT_TEMP_DIR)).getAbsoluteFile();
  }
  if (modules.isEmpty()) {
    throw new BuildException("String_Node_Str");
  }
  if (attrs.get(ANT_INVOKER_PARAM_BASEDIR) == null) {
    attrs.put(ANT_INVOKER_PARAM_BASEDIR,getProject().getBaseDir().getAbsolutePath());
  }
  for (  final Param p : pipelineParams) {
    if (!p.isValid()) {
      throw new BuildException("String_Node_Str");
    }
    final String ifProperty=p.getIf();
    final String unlessProperty=p.getUnless();
    if ((ifProperty == null || getProject().getProperties().containsKey(ifProperty)) && (unlessProperty == null || !getProject().getProperties().containsKey(unlessProperty))) {
      attrs.put(p.getName(),p.getValue());
    }
  }
}
Program: 100627
Project: 100627
Buggy source:
@Override public void endDocument() throws SAXException {
  final int size=indexTermList.size();
  updateIndexTermTargetName();
  for (  final IndexTerm indexterm : indexTermList) {
    result.addTerm(indexterm);
  }
}

Fixed version (ground truth):
@Override public void endDocument() throws SAXException {
  updateIndexTermTargetName();
  for (  final IndexTerm indexterm : indexTermList) {
    result.addTerm(indexterm);
  }
}
Program: 100628
Project: 100628
Buggy source:
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes atts) throws SAXException {
  if (SVG_NS.equals(SVG_NS) && (SVG_ELEM.equals(localName) || SVG_ELEM.equals(qName) || (qName != null && qName.startsWith(SVG_ELEM + "String_Node_Str")))) {
    dimensions.width=atts.getValue(WIDTH_ATTR);
    dimensions.height=atts.getValue(HEIGHT_ATTR);
  }
}

Fixed version (ground truth):
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes atts) throws SAXException {
  if (SVG_NS.equals(uri) && (SVG_ELEM.equals(localName) || SVG_ELEM.equals(qName) || (qName != null && qName.startsWith(SVG_ELEM + "String_Node_Str")))) {
    dimensions.width=atts.getValue(WIDTH_ATTR);
    dimensions.height=atts.getValue(HEIGHT_ATTR);
  }
}
Program: 100629
Project: 100629
Buggy source:
/** 
 * Get base path from a path.
 * @param aURLString UNIX or URI path
 * @return base path
 */
public static String getFullPathNoEndSeparator(final String aURLString){
  final int pathnameStartIndex=aURLString.indexOf(UNIX_SEPARATOR);
  final int pathnameEndIndex=aURLString.lastIndexOf(UNIX_SEPARATOR);
  String aPath=aURLString.substring(pathnameStartIndex,pathnameEndIndex);
  aPath=aURLString.substring(0,pathnameEndIndex);
  return aPath;
}

Fixed version (ground truth):
/** 
 * Get base path from a path.
 * @param aURLString UNIX or URI path
 * @return base path
 */
public static String getFullPathNoEndSeparator(final String aURLString){
  final int pathnameStartIndex=aURLString.indexOf(UNIX_SEPARATOR);
  final int pathnameEndIndex=aURLString.lastIndexOf(UNIX_SEPARATOR);
  String aPath=aURLString.substring(0,pathnameEndIndex);
  return aPath;
}
Program: 100631
Project: 100631
Buggy source:
@Override public void startElement(final String uri,final String localName,final String name,final Attributes atts) throws SAXException {
  if (ignoreDepth > 0) {
    ignoreDepth++;
    return;
  }
  if (PR_D_CODEREF.matches(atts)) {
    ignoreDepth++;
    try {
      final URI hrefValue=toURI(atts.getValue(ATTRIBUTE_NAME_HREF));
      if (hrefValue != null) {
        File codeFile=toFile(stripFragment(currentFile.resolve(hrefValue))).getAbsoluteFile();
        if (!codeFile.exists()) {
          final URI rel=job.tempDir.toURI().relativize(codeFile.toURI());
          final Job.FileInfo fi=job.getFileInfo(rel);
          if (fi != null && fi.src.getScheme().equals("String_Node_Str")) {
            codeFile=new File(fi.src);
          }
        }
        if (codeFile.exists()) {
          logger.debug("String_Node_Str" + codeFile);
          final Charset charset=getCharset(atts.getValue(ATTRIBUTE_NAME_FORMAT));
          try (BufferedReader codeReader=new BufferedReader(new InputStreamReader(new FileInputStream(codeFile),charset))){
            copyLines(codeReader,new Range(hrefValue));
          }
 catch (          final Exception e) {
            logger.error("String_Node_Str" + codeFile,e);
          }
        }
 else {
          logger.warn(MessageUtils.getInstance().getMessage("String_Node_Str",hrefValue.toString()).setLocation(atts).toString());
        }
      }
 else {
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
 else {
    super.startElement(uri,localName,name,atts);
  }
}

Fixed version (ground truth):
@Override public void startElement(final String uri,final String localName,final String name,final Attributes atts) throws SAXException {
  if (ignoreDepth > 0) {
    ignoreDepth++;
    return;
  }
  if (PR_D_CODEREF.matches(atts)) {
    ignoreDepth++;
    try {
      final URI hrefValue=toURI(atts.getValue(ATTRIBUTE_NAME_HREF));
      if (hrefValue != null) {
        File codeFile=toFile(stripFragment(currentFile.resolve(hrefValue))).getAbsoluteFile();
        if (!codeFile.exists()) {
          final URI rel=job.tempDir.toURI().relativize(codeFile.toURI());
          final Job.FileInfo fi=job.getFileInfo(rel);
          if (fi != null && "String_Node_Str".equals(fi.src.getScheme())) {
            codeFile=new File(fi.src);
          }
        }
        if (codeFile.exists()) {
          logger.debug("String_Node_Str" + codeFile);
          final Charset charset=getCharset(atts.getValue(ATTRIBUTE_NAME_FORMAT));
          try (BufferedReader codeReader=new BufferedReader(new InputStreamReader(new FileInputStream(codeFile),charset))){
            copyLines(codeReader,new Range(hrefValue));
          }
 catch (          final Exception e) {
            logger.error("String_Node_Str" + codeFile,e);
          }
        }
 else {
          logger.warn(MessageUtils.getInstance().getMessage("String_Node_Str",hrefValue.toString()).setLocation(atts).toString());
        }
      }
 else {
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
 else {
    super.startElement(uri,localName,name,atts);
  }
}
Program: 100634
Project: 100634
Buggy source:
@Override public void write(final File filename) throws DITAOTException {
  OutputStream out=null;
  XMLStreamWriter serializer=null;
  try {
    out=new FileOutputStream(filename);
    boolean indexsee=false;
    if (this.getPipelineHashIO() != null) {
      indexsee=Boolean.valueOf(this.getPipelineHashIO().getAttribute("String_Node_Str"));
      targetExt=this.getPipelineHashIO().getAttribute(ANT_INVOKER_EXT_PARAM_TARGETEXT);
    }
    serializer=XMLOutputFactory.newInstance().createXMLStreamWriter(out,"String_Node_Str");
    serializer.writeStartDocument();
    serializer.writeStartElement("String_Node_Str");
    termCloneList=cloneIndextermList(termList);
    final int termNum=termList.size();
    for (    final IndexTerm term : termList) {
      outputIndexTerm(term,serializer,indexsee);
    }
    serializer.writeEndElement();
    serializer.writeEndDocument();
  }
 catch (  final Exception e) {
    throw new DITAOTException(e);
  }
 finally {
    if (serializer != null) {
      try {
        serializer.close();
      }
 catch (      final XMLStreamException e) {
        logger.error(e.getMessage(),e);
      }
    }
    if (out != null) {
      try {
        out.close();
      }
 catch (      final IOException e) {
        logger.error(e.getMessage(),e);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void write(final File filename) throws DITAOTException {
  OutputStream out=null;
  XMLStreamWriter serializer=null;
  try {
    out=new FileOutputStream(filename);
    boolean indexsee=false;
    if (this.getPipelineHashIO() != null) {
      indexsee=Boolean.valueOf(this.getPipelineHashIO().getAttribute("String_Node_Str"));
      targetExt=this.getPipelineHashIO().getAttribute(ANT_INVOKER_EXT_PARAM_TARGETEXT);
    }
    serializer=XMLOutputFactory.newInstance().createXMLStreamWriter(out,"String_Node_Str");
    serializer.writeStartDocument();
    serializer.writeStartElement("String_Node_Str");
    termCloneList=cloneIndextermList(termList);
    for (    final IndexTerm term : termList) {
      outputIndexTerm(term,serializer,indexsee);
    }
    serializer.writeEndElement();
    serializer.writeEndDocument();
  }
 catch (  final Exception e) {
    throw new DITAOTException(e);
  }
 finally {
    if (serializer != null) {
      try {
        serializer.close();
      }
 catch (      final XMLStreamException e) {
        logger.error(e.getMessage(),e);
      }
    }
    if (out != null) {
      try {
        out.close();
      }
 catch (      final IOException e) {
        logger.error(e.getMessage(),e);
      }
    }
  }
}
Program: 100635
Project: 100635
Buggy source:
private void outputIndexEntryEclipseIndexsee(final IndexTerm term,final XMLStreamWriter serializer) throws XMLStreamException {
  final List<IndexTermTarget> targets=term.getTargetList();
  final int targetNum=targets.size();
  if (!targets.isEmpty()) {
    for (    final IndexTermTarget target : targets) {
      final String targetUri=target.getTargetURI();
      final String targetName=target.getTargetName();
      if (targetUri == null) {
        serializer.writeStartElement("String_Node_Str");
        serializer.writeAttribute("String_Node_Str",target.getTargetName());
        serializer.writeEndElement();
      }
 else {
        serializer.writeStartElement("String_Node_Str");
        serializer.writeAttribute("String_Node_Str",replaceExtName(targetUri));
        if (targetName.trim().length() > 0) {
          serializer.writeAttribute("String_Node_Str",target.getTargetName());
        }
        serializer.writeEndElement();
      }
    }
  }
}

Fixed version (ground truth):
private void outputIndexEntryEclipseIndexsee(final IndexTerm term,final XMLStreamWriter serializer) throws XMLStreamException {
  final List<IndexTermTarget> targets=term.getTargetList();
  if (!targets.isEmpty()) {
    for (    final IndexTermTarget target : targets) {
      final String targetUri=target.getTargetURI();
      final String targetName=target.getTargetName();
      if (targetUri == null) {
        serializer.writeStartElement("String_Node_Str");
        serializer.writeAttribute("String_Node_Str",target.getTargetName());
        serializer.writeEndElement();
      }
 else {
        serializer.writeStartElement("String_Node_Str");
        serializer.writeAttribute("String_Node_Str",replaceExtName(targetUri));
        if (targetName.trim().length() > 0) {
          serializer.writeAttribute("String_Node_Str",target.getTargetName());
        }
        serializer.writeEndElement();
      }
    }
  }
}
Program: 100637
Project: 100637
Buggy source:
@Override public void startElement(final String uri,final String localName,final String name,final Attributes atts) throws SAXException {
  if (TOPIC_IMAGE.matches(atts)) {
    final XMLUtils.AttributesBuilder a=new XMLUtils.AttributesBuilder(atts);
    if (atts.getValue(ATTRIBUTE_NAME_HREF) != null) {
      final URI imgInput=getImageFile(toURI(atts.getValue(ATTRIBUTE_NAME_HREF)));
      if (imgInput != null) {
        Attributes m=cache.get(imgInput);
        if (m == null) {
          m=readMetadata(imgInput);
          cache.put(imgInput,m);
        }
        a.addAll(m);
      }
 else {
        logger.error("String_Node_Str" + imgInput + "String_Node_Str");
      }
    }
    depth=1;
    super.startPrefixMapping(DITA_OT_PREFIX,DITA_OT_NS);
    super.startElement(uri,localName,name,a.build());
  }
 else {
    if (depth > 0) {
      depth++;
    }
    super.startElement(uri,localName,name,atts);
  }
}

Fixed version (ground truth):
@Override public void startElement(final String uri,final String localName,final String name,final Attributes atts) throws SAXException {
  if (TOPIC_IMAGE.matches(atts)) {
    final XMLUtils.AttributesBuilder a=new XMLUtils.AttributesBuilder(atts);
    final String href=atts.getValue(ATTRIBUTE_NAME_HREF);
    if (href != null) {
      final URI imgInput=getImageFile(toURI(href));
      if (imgInput != null) {
        Attributes m=cache.get(imgInput);
        if (m == null) {
          m=readMetadata(imgInput);
          cache.put(imgInput,m);
        }
        a.addAll(m);
      }
 else {
        logger.error("String_Node_Str" + href + "String_Node_Str");
      }
    }
    depth=1;
    super.startPrefixMapping(DITA_OT_PREFIX,DITA_OT_NS);
    super.startElement(uri,localName,name,a.build());
  }
 else {
    if (depth > 0) {
      depth++;
    }
    super.startElement(uri,localName,name,atts);
  }
}
Program: 100639
Project: 100639
Buggy source:
/** 
 * Duplicate branches so that each   {@code ditavalref} will in a separate branch.
 */
private void splitBranches(final Element elem,final Branch filter){
  final List<Element> ditavalRefs=getChildElements(elem,DITAVAREF_D_DITAVALREF);
  if (ditavalRefs.size() > 0) {
    for (    final Element branch : ditavalRefs) {
      elem.removeChild(branch);
    }
    final List<Element> branches=new ArrayList<>(ditavalRefs.size());
    branches.add(elem);
    final Node next=elem.getNextSibling();
    for (int i=1; i < ditavalRefs.size(); i++) {
      final Element clone=(Element)elem.cloneNode(true);
      if (next != null) {
        elem.getParentNode().insertBefore(clone,next);
      }
 else {
        elem.getParentNode().appendChild(clone);
      }
      branches.add(clone);
    }
    for (int i=0; i < branches.size(); i++) {
      final Element branch=branches.get(i);
      final Element ditavalref=ditavalRefs.get(i);
      branch.insertBefore(ditavalref,branch.getFirstChild());
      final Branch currentFilter=filter.merge(ditavalref);
      processAttributes(branch,currentFilter);
      for (      final Element child : getChildElements(branch,MAP_TOPICREF)) {
        if (DITAVAREF_D_DITAVALREF.matches(child)) {
          continue;
        }
        splitBranches(child,currentFilter);
      }
    }
  }
 else {
    processAttributes(elem,filter);
    for (    final Element child : getChildElements(elem,MAP_TOPICREF)) {
      splitBranches(child,filter);
    }
  }
}

Fixed version (ground truth):
/** 
 * Duplicate branches so that each   {@code ditavalref} will in a separate branch.
 */
private void splitBranches(final Element elem,final Branch filter){
  final List<Element> ditavalRefs=getChildElements(elem,DITAVAREF_D_DITAVALREF);
  if (ditavalRefs.size() > 0) {
    for (    final Element branch : ditavalRefs) {
      elem.removeChild(branch);
    }
    final List<Element> branches=new ArrayList<>(ditavalRefs.size());
    branches.add(elem);
    final Node next=elem.getNextSibling();
    for (int i=1; i < ditavalRefs.size(); i++) {
      final Element clone=(Element)elem.cloneNode(true);
      if (next != null) {
        elem.getParentNode().insertBefore(clone,next);
      }
 else {
        elem.getParentNode().appendChild(clone);
      }
      branches.add(clone);
    }
    for (int i=0; i < branches.size(); i++) {
      final Element branch=branches.get(i);
      final Element ditavalref=ditavalRefs.get(i);
      branch.insertBefore(ditavalref,branch.getFirstChild());
      final Branch currentFilter=filter.merge(ditavalref);
      processAttributes(branch,currentFilter);
      final Branch childFilter=new Branch(currentFilter.resourcePrefix,currentFilter.resourceSuffix,null,null);
      for (      final Element child : getChildElements(branch,MAP_TOPICREF)) {
        if (DITAVAREF_D_DITAVALREF.matches(child)) {
          continue;
        }
        splitBranches(child,childFilter);
      }
    }
  }
 else {
    processAttributes(elem,filter);
    for (    final Element child : getChildElements(elem,MAP_TOPICREF)) {
      splitBranches(child,filter);
    }
  }
}
Program: 100640
Project: 100640
Buggy source:
private void processAttributes(final Element elem,final Branch filter){
  if (filter.resourcePrefix != null || filter.resourceSuffix != null) {
    final String href=elem.getAttribute(ATTRIBUTE_NAME_HREF);
    final String copyTo=elem.getAttribute(ATTRIBUTE_NAME_COPY_TO);
    final String scope=elem.getAttribute(ATTRIBUTE_NAME_SCOPE);
    if ((!href.isEmpty() || !copyTo.isEmpty()) && !scope.equals(ATTR_SCOPE_VALUE_EXTERNAL)) {
      elem.setAttribute(BRANCH_COPY_TO,generateCopyTo(copyTo.isEmpty() ? href : copyTo,filter).toString());
      if (!copyTo.isEmpty()) {
        elem.removeAttribute(ATTRIBUTE_NAME_COPY_TO);
      }
    }
  }
  if ((filter.keyscopePrefix != null || filter.keyscopeSuffix != null)) {
    final String keyscope=elem.getAttribute(ATTRIBUTE_NAME_KEYSCOPE);
    if (!keyscope.isEmpty()) {
      final StringBuilder buf=new StringBuilder();
      for (      final String key : keyscope.trim().split("String_Node_Str")) {
        if (filter.keyscopePrefix != null) {
          buf.append(filter.keyscopePrefix);
        }
        buf.append(key);
        if (filter.keyscopeSuffix != null) {
          buf.append(filter.keyscopeSuffix);
        }
        buf.append(' ');
      }
      elem.setAttribute(ATTRIBUTE_NAME_KEYSCOPE,buf.toString().trim());
    }
  }
}

Fixed version (ground truth):
private void processAttributes(final Element elem,final Branch filter){
  if (filter.resourcePrefix != null || filter.resourceSuffix != null) {
    final String href=elem.getAttribute(ATTRIBUTE_NAME_HREF);
    final String copyTo=elem.getAttribute(ATTRIBUTE_NAME_COPY_TO);
    final String scope=elem.getAttribute(ATTRIBUTE_NAME_SCOPE);
    if ((!href.isEmpty() || !copyTo.isEmpty()) && !scope.equals(ATTR_SCOPE_VALUE_EXTERNAL)) {
      elem.setAttribute(BRANCH_COPY_TO,generateCopyTo(copyTo.isEmpty() ? href : copyTo,filter).toString());
      if (!copyTo.isEmpty()) {
        elem.removeAttribute(ATTRIBUTE_NAME_COPY_TO);
      }
    }
  }
  if (filter.keyscopePrefix != null || filter.keyscopeSuffix != null) {
    final StringBuilder buf=new StringBuilder();
    final String keyscope=elem.getAttribute(ATTRIBUTE_NAME_KEYSCOPE);
    if (!keyscope.isEmpty()) {
      for (      final String key : keyscope.trim().split("String_Node_Str")) {
        if (filter.keyscopePrefix != null) {
          buf.append(filter.keyscopePrefix);
        }
        buf.append(key);
        if (filter.keyscopeSuffix != null) {
          buf.append(filter.keyscopeSuffix);
        }
        buf.append(' ');
      }
    }
 else {
      if (filter.keyscopePrefix != null) {
        buf.append(filter.keyscopePrefix);
      }
      if (filter.keyscopeSuffix != null) {
        buf.append(filter.keyscopeSuffix);
      }
    }
    elem.setAttribute(ATTRIBUTE_NAME_KEYSCOPE,buf.toString().trim());
  }
}
Program: 100641
Project: 100641
Buggy source:
/** 
 * Read key definitions
 * @param filename absolute URI to DITA map with key definitions
 */
public void read(final URI filename,final Document doc) throws DITAOTException {
  rootScope=null;
  KeyScope keyScope=readScopes(doc);
  keyScope=cascadeChildKeys(keyScope);
  keyScope=inheritParentKeys(keyScope);
  rootScope=resolveIntermediate(keyScope);
}

Fixed version (ground truth):
/** 
 * Read key definitions
 * @param filename absolute URI to DITA map with key definitions
 */
public void read(final URI filename,final Document doc) throws DITAOTException {
  currentFile=filename;
  rootScope=null;
  KeyScope keyScope=readScopes(doc);
  keyScope=cascadeChildKeys(keyScope);
  keyScope=inheritParentKeys(keyScope);
  rootScope=resolveIntermediate(keyScope);
}
Program: 100642
Project: 100642
Buggy source:
private void readKeyDefinition(final Element elem,final Map<String,KeyDef> keyDefs){
  final String keyName=elem.getAttribute(ATTRIBUTE_NAME_KEYS);
  if (!keyName.isEmpty()) {
    for (    final String key : keyName.trim().split("String_Node_Str")) {
      if (!keyDefs.containsKey(key)) {
        final Document d=builder.newDocument();
        final Element copy=(Element)d.importNode(elem,true);
        d.appendChild(copy);
        final String h=copy.getAttribute(ATTRIBUTE_NAME_HREF);
        final URI href=h.isEmpty() ? null : toURI(h);
        final String s=copy.getAttribute(ATTRIBUTE_NAME_SCOPE);
        final String scope=s.isEmpty() ? null : s;
        final KeyDef keyDef=new KeyDef(key,href,scope,null,copy);
        keyDefs.put(key,keyDef);
      }
    }
  }
}

Fixed version (ground truth):
private void readKeyDefinition(final Element elem,final Map<String,KeyDef> keyDefs){
  final String keyName=elem.getAttribute(ATTRIBUTE_NAME_KEYS);
  if (!keyName.isEmpty()) {
    for (    final String key : keyName.trim().split("String_Node_Str")) {
      if (!keyDefs.containsKey(key)) {
        final Document d=builder.newDocument();
        final Element copy=(Element)d.importNode(elem,true);
        d.appendChild(copy);
        final String h=copy.getAttribute(ATTRIBUTE_NAME_HREF);
        final URI href=h.isEmpty() ? null : toURI(h);
        final String s=copy.getAttribute(ATTRIBUTE_NAME_SCOPE);
        final String scope=s.isEmpty() ? null : s;
        final KeyDef keyDef=new KeyDef(key,href,scope,currentFile,copy);
        keyDefs.put(key,keyDef);
      }
    }
  }
}