public void setConfiguration( ITemplateEngineConfiguration configuration )
    {
        Collection<ReplaceText> replacment = configuration.getReplacment();
        StringBuilder startEscape = new StringBuilder();
        if ( !configuration.escapeXML() && replacment.size() < 1 )
        {
            return;
        }
        startEscape.append( START_ESCAPE );
        if ( configuration.escapeXML() )
        {
            startEscape.append( XML_ESCAPE );
        }

        for ( ReplaceText replaceText : replacment )
        {
            startEscape.append( START_REPLACE_ESCAPE );
            startEscape.append( replaceText.getOldText() );
            startEscape.append( BODY_REPLACE_ESCAPE );
            startEscape.append( replaceText.getNewText() );
            startEscape.append( END_REPLACE_ESCAPE );
        }

        if ( startEscape.length() > 0 )
        {
            startEscape.append( CLOSE_ESCAPE );
            setStartDocumentDirective( startEscape.toString() );
            setEndDocumentDirective( END_ESCAPE );
        }

    }
  public void setConfiguration(ITemplateEngineConfiguration configuration) {
    Collection<ReplaceText> replacment = configuration.getReplacment();
    StringBuilder startEscape = new StringBuilder();
    if (!configuration.escapeXML() && replacment.size() < 1) {
      return;
    }

    startEscape.append(START_ESCAPE);
    if (configuration.escapeXML()) {
      startEscape.append(XML_ESCAPE);
    }

    for (ReplaceText replaceText : replacment) {
      startEscape.append(START_REPLACE_ESCAPE);
      startEscape.append(replaceText.getOldText());
      startEscape.append(BODY_REPLACE_ESCAPE);
      startEscape.append(replaceText.getNewText());
      startEscape.append(END_REPLACE_ESCAPE);
    }
    if (startEscape.length() > 0) {
      startEscape.append(CLOSE_ESCAPE);
      // Freemarker escape+replace must be enclosed with CDATA because replace can contains some XML
      // elements
      startEscape.insert(0, START_CDATA);
      startEscape.append(END_CDATA);
      setStartDocumentDirective(startEscape.toString());
      setEndDocumentDirective(END_ESCAPE);
    }
  }