Escaper instances suitable for strings to be included in XML attribute values and
elements' text contents. When possible, avoid manual escaping by using templating systems and
high-level APIs that provide autoescaping. For example, consider XOM or JDOM.Note
Currently the escapers provided by this class do not escape any characters outside the ASCII character range. Unlike HTML escaping the XML escapers will not escape non-ASCII characters to their numeric entity replacements. These XML escapers provide the minimal level of escaping to ensure that the output can be safely included in a Unicode XML document.
For details on the behavior of the escapers in this class, see sections 2.2 and 2.4 of the XML specification.
| Modifier and Type | Field and Description |
|---|---|
| private static final char | |
| private static final char | |
| private static final Escaper | |
| private static final Escaper | |
| private static final Escaper |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Escaper | xmlAttributeEscaper()
Returns an |
| public static Escaper | xmlContentEscaper()
Returns an |
| MAX_ASCII_CONTROL_CHAR | back to summary |
|---|---|
| private static final char MAX_ASCII_CONTROL_CHAR | |
| MIN_ASCII_CONTROL_CHAR | back to summary |
|---|---|
| private static final char MIN_ASCII_CONTROL_CHAR | |
| XML_ATTRIBUTE_ESCAPER | back to summary |
|---|---|
| private static final Escaper XML_ATTRIBUTE_ESCAPER | |
| XML_CONTENT_ESCAPER | back to summary |
|---|---|
| private static final Escaper XML_CONTENT_ESCAPER | |
| XML_ESCAPER | back to summary |
|---|---|
| private static final Escaper XML_ESCAPER | |
| XmlEscapers | back to summary |
|---|---|
| private XmlEscapers() | |
| xmlAttributeEscaper | back to summary |
|---|---|
| public static Escaper xmlAttributeEscaper() Returns an This escaper substitutes This escaper does not escape non-ASCII characters to their numeric character references
(NCR). However, horizontal tab This escaper does not treat surrogate pairs specially and does not perform Unicode validation on its input. | |
| xmlContentEscaper | back to summary |
|---|---|
| public static Escaper xmlContentEscaper() Returns an Note Double and single quotes are not escaped, so it is not safe to use this
escaper to escape attribute values. Use This escaper substitutes This escaper does not escape non-ASCII characters to their numeric character references (NCR). Any non-ASCII characters appearing in the input will be preserved in the output. Specifically "\r" (carriage return) is preserved in the output, which may result in it being silently converted to "\n" when the XML is parsed. This escaper does not treat surrogate pairs specially and does not perform Unicode validation on its input. | |