Skip to content

Namespaces MVP#37

Draft
TheSchemm wants to merge 16 commits intoPoiScript:masterfrom
TheSchemm:namespaces
Draft

Namespaces MVP#37
TheSchemm wants to merge 16 commits intoPoiScript:masterfrom
TheSchemm:namespaces

Conversation

@TheSchemm
Copy link

@TheSchemm TheSchemm commented May 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for namespaces: how hard?

1 participant