public final class XmlNameProcessors extends Object
XmlNameProcessor implementations.
Processors should be set in the XmlMapper.setXmlNameProcessor(XmlNameProcessor)
and/or the XmlMapper.Builder.xmlNameProcessor(XmlNameProcessor) methods.
| Modifier and Type | Method and Description |
|---|---|
static XmlNameProcessor |
newAlwaysOnBase64Processor()
Similar to
newBase64Processor(String), however, names will
always be escaped with base64. |
static XmlNameProcessor |
newBase64Processor()
Convenience method
equivalent to calling
newBase64Processor(String) with "base64_tag_" |
static XmlNameProcessor |
newBase64Processor(String prefix)
Generates a new processor that escapes all names that contains characters
OTHER than following characters:
Lower- or upper-case ASCII letter (a to z, A to Z)
Digit (0 to 9) in position OTHER than the first characters
Underscore
Hyphen (
-) in position OTHER than the first character
Colon (only exposed if underlying parser is in non-namespace-aware mode)
with a base64-encoded version. |
static XmlNameProcessor |
newPassthroughProcessor()
Generates a new processor that does nothing and just passes through the
names as-is.
|
static XmlNameProcessor |
newReplacementProcessor()
Convenience method
equivalent to calling
newReplacementProcessor(String) with "_" |
static XmlNameProcessor |
newReplacementProcessor(String replacement)
Generates a new processor that replaces all characters that are NOT one of:
Lower- or upper-case ASCII letter (a to z, A to Z)
Digit (0 to 9) in position OTHER than the first character
Underscore
Hyphen (
-) in position OTHER than the first character
Colon (only exposed if underlying parser is in non-namespace-aware mode)
in an
XML name with a replacement string. |
public static XmlNameProcessor newPassthroughProcessor()
With this processor set, a map with the keys "123" and
"$ I am <fancy>! &;" will be written as:
<DTO>
<badMap>
<$ I am <fancy>! &;>xyz</$ I am <fancy>! &;>
<123>bar</123>
</badMap>
</DTO>
This is the default behavior for backwards compatibility.
public static XmlNameProcessor newReplacementProcessor(String replacement)
-) in position OTHER than the first character
With this processor set (and "_" as the replacement string), a map
with the keys "123" and "$ I am <fancy>! &;" will be written as:
NOTE: this processor works for US-ASCII based element and attribute names but is unlikely to work well for many "international" use cases.
<DTO>
<badMap>
<__I_am__fancy_____>xyz</__I_am__fancy_____>
<_23>bar</_23>
</badMap>
</DTO>
replacement - The replacement string to replace invalid characters withpublic static XmlNameProcessor newReplacementProcessor()
newReplacementProcessor(String) with "_"public static XmlNameProcessor newBase64Processor(String prefix)
-) in position OTHER than the first character
= padding characters are
always omitted.
With this processor set, a map with the keys "123" and
"$ I am <fancy>! &;" will be written as:
<DTO>
<badMap>
<base64_tag_JCBJIGFtIDxmYW5jeT4hICY7>xyz</base64_tag_JCBJIGFtIDxmYW5jeT4hICY7>
<base64_tag_MTIz>bar</base64_tag_MTIz>
</badMap>
</DTO>
NOTE: you must ensure that no incoming element or attribute name starts
with prefix, otherwise decoding will not work.
prefix - The prefix to use for name that are escapedpublic static XmlNameProcessor newBase64Processor()
newBase64Processor(String) with "base64_tag_"public static XmlNameProcessor newAlwaysOnBase64Processor()
newBase64Processor(String), however, names will
always be escaped with base64. No magic prefix is required
for this case, since adding one would be redundant because all names
will be base64 encoded.Copyright © 2022 FasterXML. All rights reserved.