deser-xml
XML support for deser.
use ;
let feed: Feed = from_str.unwrap;
assert_eq!;
let xml = to_string.unwrap;
- Attributes are entries with an
@prefix, text is the$textentry. - Elements are multimaps:
Vec<T>fields collect all child elements with their name, also if other elements are between them. - Elements with attributes are their text for types that expect text, elements that are only text are maps for structs.
- Names are kept as written, namespaces can be given fixed prefixes or
be resolved into
{uri}localnames (qname!,namespace!) which the serializer writes with configured (prefixes!) or generated prefixes. Root<T>captures the name of the root element and the namespaces declared on it, and writes them. Values that keep event data (likeRecordinganddeser_value::Value) keep them too, as well as the namespace declarations of the other elements, so documents that are read into them or transcoded keep their root element and namespaces.deser_xml::Serializerimplements deser'sSerializertrait for code that does not know the format upfront (likedeser-transcode). Values without a name (like maps) need aRootorSerializerConfig::set_root.SerializerConfig::set_prettyindents child elements where the whitespace is not text, mixed content stays on a single line.- Parsing is done by quick-xml, the events are passed on while the document is parsed and text is borrowed from the input where possible.
- With the
iofeature (enabled by default) documents are read withfrom_readerand written withto_writer(ordeser::io). The output is written while the value is serialized, elements are held back only until no more attributes can come for them.
This is an early version.