XmlNameProcessor implementations.
Processors should be set using builder methods used in creating
XmlFactory instances; see XmlFactoryBuilder.
-
Method Summary
Modifier and TypeMethodDescriptionstatic XmlNameProcessorSimilar tonewBase64Processor(String), however, names will always be escaped with base64.static XmlNameProcessorConvenience method equivalent to callingnewBase64Processor(String)with"base64_tag_"static XmlNameProcessornewBase64Processor(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 XmlNameProcessorGenerates a new processor that does nothing and just passes through the names as-is.static XmlNameProcessorConvenience method equivalent to callingnewReplacementProcessor(String)with"_"static XmlNameProcessornewReplacementProcessor(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.
-
Method Details
-
newPassthroughProcessor
Generates a new processor that does nothing and just passes through the names as-is. Using this processor may generate invalid XML.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.
-
newReplacementProcessor
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)
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>- Parameters:
replacement- The replacement string to replace invalid characters with
-
newReplacementProcessor
Convenience method equivalent to callingnewReplacementProcessor(String)with"_" -
newBase64Processor
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)
=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.- Parameters:
prefix- The prefix to use for name that are escaped
-
newBase64Processor
Convenience method equivalent to callingnewBase64Processor(String)with"base64_tag_" -
newAlwaysOnBase64Processor
Similar tonewBase64Processor(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.
-