Class XmlEscape

Object
org.unbescape.xml.XmlEscape

public final class XmlEscape extends Object

Utility class for performing XML escape/unescape operations.

Configuration of escape/unescape operations

Escape operations can be (optionally) configured by means of:

  • Level, which defines how deep the escape operation must be (what chars are to be considered eligible for escaping, depending on the specific needs of the scenario). Its values are defined by the XmlEscapeLevel enum.
  • Type, which defines whether escaping should be performed by means of CERs (Character Entity References) or by means of decimal/hexadecimal numerical references. Its values are defined by the XmlEscapeType enum.

Unescape operations need no configuration parameters. Unescape operations will always perform complete unescape of CERs, decimal and hexadecimal references.

Features

This class supports both XML 1.0 and XML 1.1 escape/unescape operations. Whichever the XML version used, only the five predefined XML character entities are supported: <, >, &, &quot and '. This means there is no support for DTD-defined or user-defined entities.

Each version of XML establishes a series of characters that are considered not-valid, even when escaped —for example, the \u0000 (null byte)—. Escape operations will automatically remove these chars.

Also, each version of XML establishes a series of control characters that, even if allowed as valid characters, should always appear escaped. For example: \u0001 to \u0008 in XML 1.1.

This class supports the whole Unicode character set: \u0000 to \u10FFFF, including characters not representable by only one char in Java (>\uFFFF).

Input/Output

There are four different input/output modes that can be used in escape/unescape operations:

  • String input, String output: Input is specified as a String object and output is returned as another. In order to improve memory performance, all escape and unescape operations will return the exact same input object as output if no escape/unescape modifications are required.
  • String input, java.io.Writer output: Input will be read from a String and output will be written into the specified java.io.Writer.
  • java.io.Reader input, java.io.Writer output: Input will be read from a Reader and output will be written into the specified java.io.Writer.
  • char[] input, java.io.Writer output: Input will be read from a char array (char[]) and output will be written into the specified java.io.Writer. Two int arguments called offset and len will be used for specifying the part of the char[] that should be escaped/unescaped. These methods should be called with offset = 0 and len = text.length in order to process the whole char[].
Glossary
ER
XML Entity Reference: references to variables used to define shortcuts to standard text or special characters. Entity references start with '&' and end with ';'.
CER
Character Entity Reference: XML Entity Reference used to define a shortcut to a specific character. XML specifies five predefined CERs: &lt; (<), &gt; (>), &amp; (&), &quot; (") and &apos; (').
DCR
Decimal Character Reference: base-10 numerical representation of an Unicode codepoint: &#225;
HCR
Hexadecimal Character Reference: hexadecimal numerical representation of an Unicode codepoint: á. Note that XML only allows lower-case 'x' for defining hexadecimal character entity references (in contrast with HTML, which allows both '&#x...;' and '&#x...;').
Unicode Codepoint
Each of the int values conforming the Unicode code space. Normally corresponding to a Java char primitive value (codepoint <= \uFFFF), but might be two chars for codepoints \u10000 to \u10FFFF if the first char is a high surrogate (\uD800 to \uDBFF) and the second is a low surrogate (\uDC00 to \uDFFF).
References

The following references apply:

Since:
1.0.0
Author:
Daniel Fernández
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    escapeXml10(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.
    static void
    escapeXml10(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.0 escape operation on a char[] input.
    static void
    escapeXml10(Reader reader, Writer writer)
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
    static void
    escapeXml10(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.0 escape operation on a Reader input, writing results to a Writer.
    static String
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.
    static void
    escapeXml10(String text, Writer writer)
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
    static void
    escapeXml10(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.0 escape operation on a String input, writing results to a Writer.
    static String
    Perform a (configurable) XML 1.0 escape operation on a String input.
    static void
    escapeXml10Attribute(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.
    static void
    escapeXml10Attribute(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.0 escape operation on a char[] input meant to be an XML attribute value.
    static void
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static void
    Perform a (configurable) XML 1.0 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.
    static void
    Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static void
    Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value.
    static void
    escapeXml10AttributeMinimal(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.
    static void
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.
    static void
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static void
    escapeXml10Minimal(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input.
    static void
    escapeXml10Minimal(Reader reader, Writer writer)
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.
    static String
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input.
    static void
    Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.
    static void
    escapeXml11(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.
    static void
    escapeXml11(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.1 escape operation on a char[] input.
    static void
    escapeXml11(Reader reader, Writer writer)
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
    static void
    escapeXml11(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.1 escape operation on a Reader input, writing results to a Writer.
    static String
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.
    static void
    escapeXml11(String text, Writer writer)
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
    static void
    escapeXml11(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.1 escape operation on a String input, writing results to a Writer.
    static String
    Perform a (configurable) XML 1.1 escape operation on a String input.
    static void
    escapeXml11Attribute(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.
    static void
    escapeXml11Attribute(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level)
    Perform a (configurable) XML 1.1 escape operation on a char[] input meant to be an XML attribute value.
    static void
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static void
    Perform a (configurable) XML 1.1 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.
    static void
    Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static void
    Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value.
    static void
    escapeXml11AttributeMinimal(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.
    static void
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
    static String
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.
    static void
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
    static void
    escapeXml11Minimal(char[] text, int offset, int len, Writer writer)
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input.
    static void
    escapeXml11Minimal(Reader reader, Writer writer)
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.
    static String
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input.
    static void
    Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.
    static void
    unescapeXml(char[] text, int offset, int len, Writer writer)
    Perform an XML unescape operation on a char[] input.
    static void
    unescapeXml(Reader reader, Writer writer)
    Perform an XML unescape operation on a Reader input, writing results to a Writer.
    static String
    Perform an XML unescape operation on a String input.
    static void
    unescapeXml(String text, Writer writer)
    Perform an XML unescape operation on a String input, writing results to a Writer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • escapeXml10Minimal

      public static String escapeXml10Minimal(String text)

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml11Minimal

      public static String escapeXml11Minimal(String text)

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml10AttributeMinimal

      public static String escapeXml10AttributeMinimal(String text)

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml11AttributeMinimal

      public static String escapeXml11AttributeMinimal(String text)

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml10

      public static String escapeXml10(String text)

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml11

      public static String escapeXml11(String text)

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml10Attribute

      public static String escapeXml10Attribute(String text)

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml11Attribute

      public static String escapeXml11Attribute(String text)

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml10

      public static String escapeXml10(String text, XmlEscapeType type, XmlEscapeLevel level)

      Perform a (configurable) XML 1.0 escape operation on a String input.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other String-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml11

      public static String escapeXml11(String text, XmlEscapeType type, XmlEscapeLevel level)

      Perform a (configurable) XML 1.1 escape operation on a String input.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other String-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • escapeXml10Attribute

      public static String escapeXml10Attribute(String text, XmlEscapeType type, XmlEscapeLevel level)

      Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other String-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml11Attribute

      public static String escapeXml11Attribute(String text, XmlEscapeType type, XmlEscapeLevel level)

      Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other String-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Returns:
      The escaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no escaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
      Since:
      1.1.5
    • escapeXml10Minimal

      public static void escapeXml10Minimal(String text, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11Minimal

      public static void escapeXml11Minimal(String text, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10AttributeMinimal

      public static void escapeXml10AttributeMinimal(String text, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11AttributeMinimal

      public static void escapeXml11AttributeMinimal(String text, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(String text, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11

      public static void escapeXml11(String text, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10Attribute

      public static void escapeXml10Attribute(String text, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(String text, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a String input, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other String/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11

      public static void escapeXml11(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a String input, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other String/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10Attribute

      public static void escapeXml10Attribute(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other String/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(String text, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other String/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the String to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10Minimal

      public static void escapeXml10Minimal(Reader reader, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11Minimal

      public static void escapeXml11Minimal(Reader reader, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10AttributeMinimal

      public static void escapeXml10AttributeMinimal(Reader reader, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11AttributeMinimal

      public static void escapeXml11AttributeMinimal(Reader reader, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(Reader reader, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11

      public static void escapeXml11(Reader reader, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10Attribute

      public static void escapeXml10Attribute(Reader reader, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(Reader reader, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a Reader input, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other Reader/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml11

      public static void escapeXml11(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a Reader input, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other Reader/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • escapeXml10Attribute

      public static void escapeXml10Attribute(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other Reader/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(Reader reader, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other Reader/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be escaped.
      type - the type of escape operation to be performed, see XmlEscapeType.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10Minimal

      public static void escapeXml10Minimal(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml11Minimal

      public static void escapeXml11Minimal(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml10AttributeMinimal

      public static void escapeXml10AttributeMinimal(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11AttributeMinimal

      public static void escapeXml11AttributeMinimal(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.

      Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml11

      public static void escapeXml11(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      This method calls escapeXml11(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml10Attribute

      public static void escapeXml10Attribute(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.

      Level 2 means this method will escape:

      • The five markup-significant characters: <, >, &, " and '
      • All non ASCII characters.

      This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '&lt;') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '&#x2430;') when there there is no CER for the replaced character.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      This method calls escapeXml11(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel) with the following preconfigured values:

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml10

      public static void escapeXml10(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a char[] input.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other char[]-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml11

      public static void escapeXml11(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a char[] input.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      All other char[]-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
    • escapeXml10Attribute

      public static void escapeXml10Attribute(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.0 escape operation on a char[] input meant to be an XML attribute value.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other char[]-based escapeXml10*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • escapeXml11Attribute

      public static void escapeXml11Attribute(char[] text, int offset, int len, Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws IOException

      Perform a (configurable) XML 1.1 escape operation on a char[] input meant to be an XML attribute value.

      This method will perform an escape operation according to the specified XmlEscapeType and XmlEscapeLevel argument values.

      Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.

      All other char[]-based escapeXml11*(...) methods call this one with preconfigured type and level values.

      This method is thread-safe.

      Parameters:
      text - the char[] to be escaped.
      offset - the position in text at which the escape operation should start.
      len - the number of characters in text that should be escaped.
      writer - the java.io.Writer to which the escaped result will be written. Nothing will be written at all to this writer if input is null.
      type - the type of escape operation to be performed, see XmlEscapeType.
      level - the escape level to be applied, see XmlEscapeLevel.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.5
    • unescapeXml

      public static String unescapeXml(String text)

      Perform an XML unescape operation on a String input.

      No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.

      This method is thread-safe.

      Parameters:
      text - the String to be unescaped.
      Returns:
      The unescaped result String. As a memory-performance improvement, will return the exact same object as the text input argument if no unescaping modifications were required (and no additional String objects will be created during processing). Will return null if input is null.
    • unescapeXml

      public static void unescapeXml(String text, Writer writer) throws IOException

      Perform an XML unescape operation on a String input, writing results to a Writer.

      No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.

      This method is thread-safe.

      Parameters:
      text - the String to be unescaped.
      writer - the java.io.Writer to which the unescaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • unescapeXml

      public static void unescapeXml(Reader reader, Writer writer) throws IOException

      Perform an XML unescape operation on a Reader input, writing results to a Writer.

      No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.

      This method is thread-safe.

      Parameters:
      reader - the Reader reading the text to be unescaped.
      writer - the java.io.Writer to which the unescaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs
      Since:
      1.1.2
    • unescapeXml

      public static void unescapeXml(char[] text, int offset, int len, Writer writer) throws IOException

      Perform an XML unescape operation on a char[] input.

      No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.

      This method is thread-safe.

      Parameters:
      text - the char[] to be unescaped.
      offset - the position in text at which the unescape operation should start.
      len - the number of characters in text that should be unescaped.
      writer - the java.io.Writer to which the unescaped result will be written. Nothing will be written at all to this writer if input is null.
      Throws:
      IOException - if an input/output exception occurs