Struct xml::writer::config::EmitterConfig
[−]
[src]
pub struct EmitterConfig { pub line_separator: String, pub indent_string: String, pub perform_indent: bool, pub write_document_declaration: bool, pub normalize_empty_elements: bool, pub cdata_to_characters: bool, }
Emitter configuration structure.
This structure contains various options which control XML document emitter behavior.
Fields
line_separator | Line separator used to separate lines in formatted output. Default is |
indent_string | A string which will be used for a single level of indentation. Default is |
perform_indent | Whether or not the emitted document should be indented. Default is false. The emitter is capable to perform automatic indentation of the emitted XML document. It is done in stream-like fashion and does not require the knowledge of the whole document in advance. Sometimes, however, automatic indentation is undesirable, e.g. when you want to keep existing layout when processing an existing XML document. Also the indentiation algorithm is not thoroughly tested. Hence by default it is disabled. |
write_document_declaration | Whether or not to write XML document declaration at the beginning of a document. Default is true. This option controls whether the document declaration should be emitted automatically before a root element is written if it was not emitted explicitly by the user. |
normalize_empty_elements | Whether or not to convert elements with empty content to empty elements. Default is true. This option allows turning elements like |
cdata_to_characters | Whether or not to emit CDATA events as plain characters. Default is false. This option forces the emitter to convert CDATA events into regular character events, performing all the necessary escaping beforehand. This may be occasionally useful for feeding the document into incorrect parsers which do not support CDATA. |
Methods
impl EmitterConfig
fn new() -> EmitterConfig
Creates an emitter configuration with default values.
You can tweak default options with builder-like pattern:
rust let config = EmitterConfig::new() .line_separator("\r\n".to_owned()) .perform_indent(true) .normalize_empty_elements(false);
impl EmitterConfig
fn line_separator(self, value: String) -> EmitterConfig
Sets the field to the provided value and returns updated config object.
impl EmitterConfig
fn indent_string(self, value: String) -> EmitterConfig
Sets the field to the provided value and returns updated config object.
impl EmitterConfig
fn perform_indent(self, value: bool) -> EmitterConfig
Sets the field to the provided value and returns updated config object.
impl EmitterConfig
fn write_document_declaration(self, value: bool) -> EmitterConfig
Sets the field to the provided value and returns updated config object.
impl EmitterConfig
fn normalize_empty_elements(self, value: bool) -> EmitterConfig
Sets the field to the provided value and returns updated config object.
impl EmitterConfig
fn cdata_to_characters(self, value: bool) -> EmitterConfig
Sets the field to the provided value and returns updated config object.