strong-xml
strong-xml copied to clipboard
Namespaces MVP
This is a pretty simple implementation of namespaces. Fixes #22.
Example Usage:
#[derive(XmlWrite, XmlRead, PartialEq, Debug)]
#[xml(tag = "n:nested", ns = "n: http://www.example.com")]
struct Nested {
#[xml(child = "n:nested")]
contents: Vec<Nested>,
}
Note the space between n: and http://www.example.com.
Using the default namespace would just be: #[xml(tag = "nested", ns = "http://www.example.com")]
Features:
- Fully backward compatible implementation; all original tests pass.
- It serializes missing namespaces that are used by nested structs when the child element is written.
- Implemented so that static validation would be easier to write, as namespaces have to be kept track of while writing.
Todos:
- Does not validate yet.
- Some additional refactoring can (should) be done around how prefixes and how namespaces are kept track of
- Currently can only declare namespaces at the type level. Adding support for namespaces on nested types wouldn't be difficult.