@Override public void escape(char[] buffer,int start,int length,boolean isAttributeValue,Writer outputWriter) throws IOException {
  for (int i=start; i < start + length; i++) {
    char ch=buffer[i];
    if (ch == '&') {
      outputWriter.write("&amp;");
      continue;
    }
    if (ch == '<') {
      outputWriter.write("&lt;");
      continue;
    }
    if (ch == '>') {
      outputWriter.write("&gt;");
      continue;
    }
    if (ch == '"' && isAttributeValue) {
      outputWriter.write("&quot;");
      continue;
    }
    if (ch == '\'' && isAttributeValue) {
      outputWriter.write("&apos;");
      continue;
    }
    if (isXml11RestrictedCharacter(ch)) {
      outputWriter.write("&#x");
      outputWriter.write(Integer.toHexString(ch));
      outputWriter.write(";");
      continue;
    }
    outputWriter.write(ch);
  }
}

@ Override public void escape ( char [ ] buffer , int start , int length , boolean isAttributeValue , Writer outputWriter ) throws IOException { for ( int i = start ; i < start + length ; i ++ ) { char ch = buffer [ i ] ; if ( ch == '&' ) { outputWriter . write ( "&amp;" ) ; continue ; } if ( ch == '<' ) { outputWriter . write ( "&lt;" ) ; continue ; } if ( ch == '>' ) { outputWriter . write ( "&gt;" ) ; continue ; } if ( ch == '"' && isAttributeValue ) { outputWriter . write ( "&quot;" ) ; continue ; } if ( ch == '\'' && isAttributeValue ) { outputWriter . write ( "&apos;" ) ; continue ; } if ( isXml11RestrictedCharacter ( ch ) ) { outputWriter . write ( "&#x" ) ; outputWriter . write ( Integer . toHexString ( ch ) ) ; outputWriter . write ( ";" ) ; continue ; } outputWriter . write ( ch ) ; } }
escape restricted xml 1 . 1 characters inside the buffer and send the output to the writer . the " & " , " < " , and " > " characters are always escaped . single and double quotes are escaped when within an attribute . all xml 1 . 1 restricted characters are escaped using " & # x ( value ) ; " .
