code: private String escapeXmlValue(String value, boolean isAttrValue) {
          if (value == null)
              throw new IllegalArgumentException();
          return StringGroovyMethods.collectReplacements(value, new ReplacingClosure(isAttrValue, useDoubleQuotes));
      }
docs: Escapes a string so that it can be used in XML text successfully.
  It replaces the following characters with the corresponding XML
  entities:
  <ul>
  <li>&amp; as &amp;amp;</li>
  <li>&lt; as &amp;lt;</li>
  <li>&gt; as &amp;gt;</li>
  </ul>
  If the string is to be added as an attribute value, these
  characters are also escaped:
  <ul>
  <li>' as &amp;apos;</li>
  </ul>
  
  @param value       The string to escape.
  @param isAttrValue <code>true</code> if the string is to be used
  as an attribute value, otherwise <code>false</code>.
  @return A new string in which all characters that require escaping
  have been replaced with the corresponding XML entities.