public class XmlNormalizer
extends java.lang.Object
| Constructor and Description |
|---|
XmlNormalizer() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
normalize(java.lang.String s)
Normalizes a string to not conflict with XML markup characters.
|
static java.lang.String |
normalizeXMLEmbeddedTextOnly(java.lang.String xmlString)
Normalizes any text in between quotes ("text") or text given as character data of mixed-content elements,
all inside
xmlString. |
static java.lang.String |
translate(char ch)
Translates the given character
ch to its masked XML representation
if this character is one of { <, >, &, ", ' }. |
public static java.lang.String normalize(java.lang.String s)
s does contain such markup.
Otherwise s is returned.public static java.lang.String normalizeXMLEmbeddedTextOnly(java.lang.String xmlString)
xmlString. Other text is left untouched.
This method can be used to fix illegal text in an unparsable XML document,
without destroying the XML markup itself.
Note that some rather simple parsing is used, and that there may be cases in which the result is undesirable. Thus this method should only be used as a fallback solution when the XML string can not be parsed with a regular XML parser.
xmlString - public static java.lang.String translate(char ch)
ch to its masked XML representation
if this character is one of { <, >, &, ", ' }.
Otherwise returns null.ch -