Program: 100773
Project: 100773
Buggy source:
private void processChunk(final Element element,final File outputFile){
  final String hrefValue=element.getAttribute(ATTRIBUTE_NAME_HREF);
  final String chunkValue=element.getAttribute(ATTRIBUTE_NAME_CHUNK);
  final String copytoValue=element.getAttribute(ATTRIBUTE_NAME_COPY_TO);
  final String scopeValue=element.getAttribute(ATTRIBUTE_NAME_SCOPE);
  final String classValue=element.getAttribute(ATTRIBUTE_NAME_CLASS);
  final String processRoleValue=element.getAttribute(ATTRIBUTE_NAME_PROCESSING_ROLE);
  final String id=element.getAttribute(ATTRIBUTE_NAME_ID);
  final String navtitle=element.getAttribute(ATTRIBUTE_NAME_NAVTITLE);
  String parseFilePath=null;
  File outputFileName=outputFile;
  Writer tempWriter=new StringWriter();
  Set<String> tempTopicID=new HashSet<String>();
  targetTopicId=null;
  selectMethod=ATTR_CHUNK_VALUE_SELECT_DOCUMENT;
  include=false;
  boolean needWriteDitaTag=true;
  try {
    if (copytoValue.length() != 0 && !chunkValue.contains(ATTR_CHUNK_VALUE_TO_CONTENT)) {
      if (getFragment(hrefValue) != null) {
        parseFilePath=setFragment(copytoValue,getFragment(hrefValue));
      }
 else {
        parseFilePath=copytoValue;
      }
    }
 else {
      parseFilePath=hrefValue;
    }
    if (copytoValue.length() != 0 && chunkValue.contains(ATTR_CHUNK_VALUE_TO_CONTENT) && hrefValue.length() != 0) {
      copyto.add(copytoValue);
      if (getFragment(hrefValue) != null) {
        copytoSource.add(stripFragment(hrefValue));
        copytotarget2source.put(toFile(copytoValue),toFile(stripFragment(hrefValue)));
      }
 else {
        copytoSource.add(hrefValue);
        copytotarget2source.put(toFile(copytoValue),toFile(hrefValue));
      }
    }
    if (!StringUtils.isEmptyString(classValue)) {
      if ((!MAPGROUP_D_TOPICGROUP.matches(classValue)) && (!StringUtils.isEmptyString(parseFilePath)) && (!ATTR_SCOPE_VALUE_EXTERNAL.equals(scopeValue))) {
        if (chunkValue.indexOf(ATTR_CHUNK_VALUE_TO_CONTENT) != -1) {
          tempWriter=output;
          tempTopicID=topicID;
          output=new StringWriter();
          topicID=new HashSet<String>();
          if (MAP_MAP.matches(classValue)) {
            outputFileName=FileUtils.resolveFile(filePath,parseFilePath);
            needWriteDitaTag=false;
          }
 else           if (copytoValue.length() != 0) {
            outputFileName=FileUtils.resolveFile(filePath,copytoValue);
          }
 else           if (hrefValue.length() != 0) {
            if (chunkValue.contains(ATTR_CHUNK_VALUE_SELECT_TOPIC) || chunkValue.contains(ATTR_CHUNK_VALUE_SELECT_BRANCH)) {
              if (getFragment(hrefValue) != null) {
                outputFileName=FileUtils.resolveFile(filePath,getFragment(hrefValue) + FILE_EXTENSION_DITA);
              }
 else {
                final String firstTopic=this.getFirstTopicId(FileUtils.resolveFile(filePath,hrefValue).getPath());
                if (!StringUtils.isEmptyString(firstTopic)) {
                  outputFileName=FileUtils.resolveFile(filePath,firstTopic + FILE_EXTENSION_DITA);
                }
 else {
                  outputFileName=FileUtils.resolveFile(filePath,hrefValue);
                }
              }
            }
 else {
              outputFileName=FileUtils.resolveFile(filePath,hrefValue);
            }
          }
 else {
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
          }
          if (outputFileName.exists() && !MAP_MAP.matches(classValue)) {
            final File t=outputFileName;
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
            conflictTable.put(outputFileName.getPath(),t.getPath());
          }
          changeTable.put(outputFileName.getPath(),outputFileName.getPath());
        }
        this.outputFile=outputFileName;
{
          final String path=FileUtils.resolveTopic(filePath,parseFilePath);
          String newpath=null;
          if (getFragment(path) != null) {
            newpath=setFragment(outputFileName.getPath(),getFragment(path));
          }
 else {
            final String firstTopicID=this.getFirstTopicId(path);
            if (!StringUtils.isEmptyString(firstTopicID)) {
              newpath=setFragment(outputFileName.getPath(),firstTopicID);
            }
 else {
              newpath=outputFileName.getPath();
            }
          }
          changeTable.put(path,newpath);
          element.setAttribute(ATTRIBUTE_NAME_HREF,FileUtils.getRelativeUnixPath(filePath + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,newpath));
        }
        if (getFragment(parseFilePath) != null) {
          targetTopicId=getFragment(parseFilePath);
        }
        if (chunkValue.indexOf("String_Node_Str") != -1) {
          final int endIndex=chunkValue.indexOf(STRING_BLANK,chunkValue.indexOf("String_Node_Str"));
          if (endIndex == -1) {
            selectMethod=chunkValue.substring(chunkValue.indexOf("String_Node_Str"));
          }
 else {
            selectMethod=chunkValue.substring(chunkValue.indexOf("String_Node_Str"),endIndex);
          }
          if (ATTR_CHUNK_VALUE_SELECT_TOPIC.equals(selectMethod) || ATTR_CHUNK_VALUE_SELECT_BRANCH.equals(selectMethod)) {
            if (targetTopicId == null) {
              selectMethod=ATTR_CHUNK_VALUE_SELECT_DOCUMENT;
            }
          }
        }
        final File tempPath=currentParsingFile;
        currentParsingFile=FileUtils.resolveFile(filePath,parseFilePath);
        if (!ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(processRoleValue)) {
          currentParsingFileTopicIDChangeTable=new HashMap<String,String>();
          reader.parse(currentParsingFile.toURI().toString());
          if (currentParsingFileTopicIDChangeTable.size() > 0) {
            String href=element.getAttribute(ATTRIBUTE_NAME_HREF);
            href=FileUtils.separatorsToUnix(href);
            final String pathtoElem=getFragment(href) != null ? getFragment(href) : "String_Node_Str";
            final String old_elementid=pathtoElem.contains(SLASH) ? pathtoElem.substring(0,pathtoElem.indexOf(SLASH)) : pathtoElem;
            if (old_elementid.length() > 0) {
              final String new_elementid=currentParsingFileTopicIDChangeTable.get(old_elementid);
              if (new_elementid != null && new_elementid.length() > 0) {
                href=setFragment(href,new_elementid);
                element.setAttribute(ATTRIBUTE_NAME_HREF,href);
              }
            }
          }
          currentParsingFileTopicIDChangeTable=null;
        }
        currentParsingFile=tempPath;
      }
      if (outputFileName == null) {
        if (!StringUtils.isEmptyString(copytoValue)) {
          outputFileName=FileUtils.resolveFile(filePath,copytoValue);
        }
 else         if (!StringUtils.isEmptyString(id)) {
          outputFileName=FileUtils.resolveFile(filePath,id + FILE_EXTENSION_DITA);
        }
 else {
          outputFileName=FileUtils.resolveFile(filePath,generateFilename());
          if (outputFileName.exists() && !MAP_MAP.matches(classValue)) {
            final File t=outputFileName;
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
            conflictTable.put(outputFileName.getPath(),t.getPath());
          }
        }
        if (element.hasChildNodes() || !StringUtils.isEmptyString(navtitle)) {
          final DITAAttrUtils utils=DITAAttrUtils.getInstance();
          String navtitleValue=null;
          String shortDescValue=null;
          navtitleValue=utils.getChildElementValueOfTopicmeta(element,TOPIC_NAVTITLE.matcher);
          shortDescValue=utils.getChildElementValueOfTopicmeta(element,MAP_SHORTDESC.matcher);
          if (navtitleValue == null) {
            navtitleValue=navtitle;
          }
          changeTable.put(outputFileName.getPath(),outputFileName.getPath());
          if (!StringUtils.isEmptyString(navtitleValue)) {
            element.setAttribute(ATTRIBUTE_NAME_HREF,toURI(FileUtils.getRelativePath(new File(filePath,FILE_NAME_STUB_DITAMAP),outputFileName)).toString());
            final StringBuffer buffer=new StringBuffer();
            buffer.append("String_Node_Str").append("String_Node_Str").append(navtitleValue).append("String_Node_Str");
            if (shortDescValue != null) {
              buffer.append("String_Node_Str").append(shortDescValue).append("String_Node_Str");
            }
            buffer.append("String_Node_Str");
            final StringReader rder=new StringReader(buffer.toString());
            final InputSource source=new InputSource(rder);
            final File tempPath=currentParsingFile;
            currentParsingFile=outputFileName;
            parseFilePath=outputFileName.getPath();
            reader.parse(source);
            currentParsingFile=tempPath;
          }
        }
      }
      if (element.hasChildNodes()) {
        final StringWriter temp=(StringWriter)output;
        output=new StringWriter();
        final NodeList children=element.getChildNodes();
        for (int i=0; i < children.getLength(); i++) {
          final Node current=children.item(i);
          if (current.getNodeType() == Node.ELEMENT_NODE && ((Element)current).getAttribute(ATTRIBUTE_NAME_CLASS).indexOf(MAP_TOPICREF.matcher) != -1) {
            processChunk((Element)current,outputFileName);
          }
        }
        final StringBuffer parentResult=temp.getBuffer();
        if (parentResult.length() > 0 && !StringUtils.isEmptyString(parseFilePath) && !ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(processRoleValue)) {
          int insertpoint=parentResult.lastIndexOf("String_Node_Str");
          final int end=parentResult.indexOf("String_Node_Str",insertpoint);
          if (insertpoint == -1 || end == -1) {
            logger.logError(MessageUtils.getInstance().getMessage("String_Node_Str",hrefValue).toString());
          }
 else {
            if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint,end).trim())) {
              insertpoint=parentResult.lastIndexOf("String_Node_Str",insertpoint);
            }
            parentResult.insert(insertpoint,((StringWriter)output).getBuffer());
          }
        }
 else {
          parentResult.append(((StringWriter)output).getBuffer());
        }
        output=temp;
      }
      if (chunkValue.indexOf(ATTR_CHUNK_VALUE_TO_CONTENT) != -1) {
        final FileOutputStream fileOutput=new FileOutputStream(outputFileName);
        OutputStreamWriter ditaFileOutput=null;
        try {
          ditaFileOutput=new OutputStreamWriter(fileOutput,UTF8);
          if (outputFileName.equals(changeTable.get(outputFileName))) {
            writeStartDocument(ditaFileOutput);
            final File workDir=outputFileName.getParentFile().getAbsoluteFile();
            if (OS_NAME.toLowerCase().indexOf(OS_NAME_WINDOWS) == -1) {
              writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET,workDir.getAbsolutePath());
            }
 else {
              writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET,UNIX_SEPARATOR + workDir.getAbsolutePath());
            }
            writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET_URI,workDir.toURI().toString());
            if ((conflictTable.get(outputFileName) != null)) {
              final String relativePath=FileUtils.getRelativeUnixPath(filePath + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,conflictTable.get(outputFileName));
              String path2project=FileUtils.getRelativeUnixPath(relativePath);
              if (null == path2project) {
                path2project="String_Node_Str";
              }
              writeProcessingInstruction(ditaFileOutput,PI_PATH2PROJ_TARGET,path2project);
            }
          }
          if (needWriteDitaTag) {
            final AttributesImpl atts=new AttributesImpl();
            XMLUtils.addOrSetAttribute(atts,ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION,ditaarchNSValue);
            XMLUtils.addOrSetAttribute(atts,ATTRIBUTE_PREFIX_DITAARCHVERSION + COLON + ATTRIBUTE_NAME_DITAARCHVERSION,"String_Node_Str");
            writeStartElement(ditaFileOutput,ELEMENT_NAME_DITA,atts);
          }
          ditaFileOutput.write(((StringWriter)output).getBuffer().toString());
          if (needWriteDitaTag) {
            writeEndElement(ditaFileOutput,ELEMENT_NAME_DITA);
          }
          ditaFileOutput.flush();
        }
  finally {
          ditaFileOutput.close();
        }
        output=tempWriter;
        topicID=tempTopicID;
      }
    }
  }
 catch (  final Exception e) {
    logger.logError(e.getMessage(),e);
  }
}

Fixed version (ground truth):
private void processChunk(final Element element,final File outputFile){
  final String hrefValue=element.getAttribute(ATTRIBUTE_NAME_HREF);
  final String chunkValue=element.getAttribute(ATTRIBUTE_NAME_CHUNK);
  final String copytoValue=element.getAttribute(ATTRIBUTE_NAME_COPY_TO);
  final String scopeValue=element.getAttribute(ATTRIBUTE_NAME_SCOPE);
  final String classValue=element.getAttribute(ATTRIBUTE_NAME_CLASS);
  final String processRoleValue=element.getAttribute(ATTRIBUTE_NAME_PROCESSING_ROLE);
  final String id=element.getAttribute(ATTRIBUTE_NAME_ID);
  final String navtitle=element.getAttribute(ATTRIBUTE_NAME_NAVTITLE);
  String parseFilePath=null;
  File outputFileName=outputFile;
  Writer tempWriter=new StringWriter();
  Set<String> tempTopicID=new HashSet<String>();
  targetTopicId=null;
  selectMethod=ATTR_CHUNK_VALUE_SELECT_DOCUMENT;
  include=false;
  boolean needWriteDitaTag=true;
  try {
    if (copytoValue.length() != 0 && !chunkValue.contains(ATTR_CHUNK_VALUE_TO_CONTENT)) {
      if (getFragment(hrefValue) != null) {
        parseFilePath=setFragment(copytoValue,getFragment(hrefValue));
      }
 else {
        parseFilePath=copytoValue;
      }
    }
 else {
      parseFilePath=hrefValue;
    }
    if (copytoValue.length() != 0 && chunkValue.contains(ATTR_CHUNK_VALUE_TO_CONTENT) && hrefValue.length() != 0) {
      copyto.add(copytoValue);
      if (getFragment(hrefValue) != null) {
        copytoSource.add(stripFragment(hrefValue));
        copytotarget2source.put(toFile(copytoValue),toFile(stripFragment(hrefValue)));
      }
 else {
        copytoSource.add(hrefValue);
        copytotarget2source.put(toFile(copytoValue),toFile(hrefValue));
      }
    }
    if (!StringUtils.isEmptyString(classValue)) {
      if ((!MAPGROUP_D_TOPICGROUP.matches(classValue)) && (!StringUtils.isEmptyString(parseFilePath)) && (!ATTR_SCOPE_VALUE_EXTERNAL.equals(scopeValue))) {
        if (chunkValue.indexOf(ATTR_CHUNK_VALUE_TO_CONTENT) != -1) {
          tempWriter=output;
          tempTopicID=topicID;
          output=new StringWriter();
          topicID=new HashSet<String>();
          if (MAP_MAP.matches(classValue)) {
            outputFileName=FileUtils.resolveFile(filePath,parseFilePath);
            needWriteDitaTag=false;
          }
 else           if (copytoValue.length() != 0) {
            outputFileName=FileUtils.resolveFile(filePath,copytoValue);
          }
 else           if (hrefValue.length() != 0) {
            if (chunkValue.contains(ATTR_CHUNK_VALUE_SELECT_TOPIC) || chunkValue.contains(ATTR_CHUNK_VALUE_SELECT_BRANCH)) {
              if (getFragment(hrefValue) != null) {
                outputFileName=FileUtils.resolveFile(filePath,getFragment(hrefValue) + FILE_EXTENSION_DITA);
              }
 else {
                final String firstTopic=this.getFirstTopicId(FileUtils.resolveFile(filePath,hrefValue).getPath());
                if (!StringUtils.isEmptyString(firstTopic)) {
                  outputFileName=FileUtils.resolveFile(filePath,firstTopic + FILE_EXTENSION_DITA);
                }
 else {
                  outputFileName=FileUtils.resolveFile(filePath,hrefValue);
                }
              }
            }
 else {
              outputFileName=FileUtils.resolveFile(filePath,hrefValue);
            }
          }
 else {
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
          }
          if (outputFileName.exists() && !MAP_MAP.matches(classValue)) {
            final File t=outputFileName;
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
            conflictTable.put(outputFileName.getPath(),t.getPath());
          }
          changeTable.put(outputFileName.getPath(),outputFileName.getPath());
        }
        this.outputFile=outputFileName;
{
          final String path=FileUtils.resolveTopic(filePath,parseFilePath);
          String newpath=null;
          if (getFragment(path) != null) {
            newpath=setFragment(outputFileName.getPath(),getFragment(path));
          }
 else {
            final String firstTopicID=this.getFirstTopicId(path);
            if (!StringUtils.isEmptyString(firstTopicID)) {
              newpath=setFragment(outputFileName.getPath(),firstTopicID);
            }
 else {
              newpath=outputFileName.getPath();
            }
          }
          changeTable.put(path,newpath);
          element.setAttribute(ATTRIBUTE_NAME_HREF,FileUtils.getRelativeUnixPath(filePath + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,newpath));
        }
        if (getFragment(parseFilePath) != null) {
          targetTopicId=getFragment(parseFilePath);
        }
        if (chunkValue.indexOf("String_Node_Str") != -1) {
          final int endIndex=chunkValue.indexOf(STRING_BLANK,chunkValue.indexOf("String_Node_Str"));
          if (endIndex == -1) {
            selectMethod=chunkValue.substring(chunkValue.indexOf("String_Node_Str"));
          }
 else {
            selectMethod=chunkValue.substring(chunkValue.indexOf("String_Node_Str"),endIndex);
          }
          if (ATTR_CHUNK_VALUE_SELECT_TOPIC.equals(selectMethod) || ATTR_CHUNK_VALUE_SELECT_BRANCH.equals(selectMethod)) {
            if (targetTopicId == null) {
              selectMethod=ATTR_CHUNK_VALUE_SELECT_DOCUMENT;
            }
          }
        }
        final File tempPath=currentParsingFile;
        currentParsingFile=FileUtils.resolveFile(filePath,parseFilePath);
        if (!ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(processRoleValue)) {
          currentParsingFileTopicIDChangeTable=new HashMap<String,String>();
          reader.parse(currentParsingFile.toURI().toString());
          if (currentParsingFileTopicIDChangeTable.size() > 0) {
            String href=element.getAttribute(ATTRIBUTE_NAME_HREF);
            href=FileUtils.separatorsToUnix(href);
            final String pathtoElem=getFragment(href) != null ? getFragment(href) : "String_Node_Str";
            final String old_elementid=pathtoElem.contains(SLASH) ? pathtoElem.substring(0,pathtoElem.indexOf(SLASH)) : pathtoElem;
            if (old_elementid.length() > 0) {
              final String new_elementid=currentParsingFileTopicIDChangeTable.get(old_elementid);
              if (new_elementid != null && new_elementid.length() > 0) {
                href=setFragment(href,new_elementid);
                element.setAttribute(ATTRIBUTE_NAME_HREF,href);
              }
            }
          }
          currentParsingFileTopicIDChangeTable=null;
        }
        currentParsingFile=tempPath;
      }
      if (outputFileName == null) {
        if (!StringUtils.isEmptyString(copytoValue)) {
          outputFileName=FileUtils.resolveFile(filePath,copytoValue);
        }
 else         if (!StringUtils.isEmptyString(id)) {
          outputFileName=FileUtils.resolveFile(filePath,id + FILE_EXTENSION_DITA);
        }
 else {
          outputFileName=FileUtils.resolveFile(filePath,generateFilename());
          if (outputFileName.exists() && !MAP_MAP.matches(classValue)) {
            final File t=outputFileName;
            outputFileName=FileUtils.resolveFile(filePath,generateFilename());
            conflictTable.put(outputFileName.getPath(),t.getPath());
          }
        }
        if (element.hasChildNodes() || !StringUtils.isEmptyString(navtitle)) {
          final DITAAttrUtils utils=DITAAttrUtils.getInstance();
          String navtitleValue=null;
          String shortDescValue=null;
          navtitleValue=utils.getChildElementValueOfTopicmeta(element,TOPIC_NAVTITLE.matcher);
          shortDescValue=utils.getChildElementValueOfTopicmeta(element,MAP_SHORTDESC.matcher);
          if (navtitleValue == null) {
            navtitleValue=navtitle;
          }
          changeTable.put(outputFileName.getPath(),outputFileName.getPath());
          if (!StringUtils.isEmptyString(navtitleValue)) {
            element.setAttribute(ATTRIBUTE_NAME_HREF,toURI(FileUtils.getRelativePath(new File(filePath,FILE_NAME_STUB_DITAMAP),outputFileName)).toString());
            final StringBuffer buffer=new StringBuffer();
            buffer.append("String_Node_Str").append("String_Node_Str").append(navtitleValue).append("String_Node_Str");
            if (shortDescValue != null) {
              buffer.append("String_Node_Str").append(shortDescValue).append("String_Node_Str");
            }
            buffer.append("String_Node_Str");
            final StringReader rder=new StringReader(buffer.toString());
            final InputSource source=new InputSource(rder);
            final File tempPath=currentParsingFile;
            currentParsingFile=outputFileName;
            parseFilePath=outputFileName.getPath();
            reader.parse(source);
            currentParsingFile=tempPath;
          }
        }
      }
      if (element.hasChildNodes()) {
        final StringWriter temp=(StringWriter)output;
        output=new StringWriter();
        final NodeList children=element.getChildNodes();
        for (int i=0; i < children.getLength(); i++) {
          final Node current=children.item(i);
          if (current.getNodeType() == Node.ELEMENT_NODE && ((Element)current).getAttribute(ATTRIBUTE_NAME_CLASS).indexOf(MAP_TOPICREF.matcher) != -1) {
            processChunk((Element)current,outputFileName);
          }
        }
        final StringBuffer parentResult=temp.getBuffer();
        if (parentResult.length() > 0 && !StringUtils.isEmptyString(parseFilePath) && !ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(processRoleValue)) {
          int insertpoint=parentResult.lastIndexOf("String_Node_Str");
          final int end=parentResult.indexOf("String_Node_Str",insertpoint);
          if (insertpoint == -1 || end == -1) {
            logger.logError(MessageUtils.getInstance().getMessage("String_Node_Str",hrefValue).toString());
          }
 else {
            if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint,end).trim())) {
              insertpoint=parentResult.lastIndexOf("String_Node_Str",insertpoint);
            }
            parentResult.insert(insertpoint,((StringWriter)output).getBuffer());
          }
        }
 else {
          parentResult.append(((StringWriter)output).getBuffer());
        }
        output=temp;
      }
      if (chunkValue.indexOf(ATTR_CHUNK_VALUE_TO_CONTENT) != -1) {
        final FileOutputStream fileOutput=new FileOutputStream(outputFileName);
        OutputStreamWriter ditaFileOutput=null;
        try {
          ditaFileOutput=new OutputStreamWriter(fileOutput,UTF8);
          if (outputFileName.getPath().equals(changeTable.get(outputFileName.getPath()))) {
            writeStartDocument(ditaFileOutput);
            final File workDir=outputFileName.getParentFile().getAbsoluteFile();
            if (OS_NAME.toLowerCase().indexOf(OS_NAME_WINDOWS) == -1) {
              writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET,workDir.getAbsolutePath());
            }
 else {
              writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET,UNIX_SEPARATOR + workDir.getAbsolutePath());
            }
            writeProcessingInstruction(ditaFileOutput,PI_WORKDIR_TARGET_URI,workDir.toURI().toString());
            if ((conflictTable.get(outputFileName.getPath()) != null)) {
              final String relativePath=FileUtils.getRelativeUnixPath(filePath + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,conflictTable.get(outputFileName.getPath()));
              String path2project=FileUtils.getRelativeUnixPath(relativePath);
              if (null == path2project) {
                path2project="String_Node_Str";
              }
              writeProcessingInstruction(ditaFileOutput,PI_PATH2PROJ_TARGET,path2project);
            }
          }
          if (needWriteDitaTag) {
            final AttributesImpl atts=new AttributesImpl();
            XMLUtils.addOrSetAttribute(atts,ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION,ditaarchNSValue);
            XMLUtils.addOrSetAttribute(atts,ATTRIBUTE_PREFIX_DITAARCHVERSION + COLON + ATTRIBUTE_NAME_DITAARCHVERSION,"String_Node_Str");
            writeStartElement(ditaFileOutput,ELEMENT_NAME_DITA,atts);
          }
          ditaFileOutput.write(((StringWriter)output).getBuffer().toString());
          if (needWriteDitaTag) {
            writeEndElement(ditaFileOutput,ELEMENT_NAME_DITA);
          }
          ditaFileOutput.flush();
        }
  finally {
          ditaFileOutput.close();
        }
        output=tempWriter;
        topicID=tempTopicID;
      }
    }
  }
 catch (  final Exception e) {
    logger.logError(e.getMessage(),e);
  }
}