@Xml Text Formats
The text-oriented XmlFormat values render a single property value directly as the character content of the element:
- XmlFormat.TEXT and XmlFormat.TEXT_PWS serialize any string-convertible value as a text node.
- XmlFormat.XMLTEXT serializes a string that is itself fully-formed XML as-is.
Text content — TEXT and TEXT_PWS
The XmlFormat.TEXT format is similar to XmlFormat.MIXED except it's meant for solitary objects that get serialized as simple child text nodes.
Any object that can be serialize to a String can be used.
The XmlFormat.TEXT_PWS is the same except
whitespace is preserved in the output.
| Data type | JSON example | Without annotations | With annotations |
|---|---|---|---|
| | | |
Embedded XML content — XMLTEXT
The XmlFormat.XMLTEXT format is similar to XmlFormat.TEXT except it's meant for strings containing XML that should be serialized as-is to the document.
Any object that can be serialize to a String can be used.
During parsing, the element content gets parsed with the rest of the document and then re-serialized to XML before being
set as the property value.
This process may not be perfect (e.g.
double quotes may be replaced by single quotes, etc...).
| Data type | JSON example | With TEXT annotation | With XMLTEXT annotation |
|---|---|---|---|
| | | |
See also
- @Xml(format) Annotation for the full list of
XmlFormatvalues. - Element & Mixed Formats for
FREEFORM,MIXED, andMIXED_PWS. - Whitespace Handling for how empty strings and whitespace are preserved in
TEXToutput.