Skip to content

feat(xml): generic namespace-aware mapping core (draft, proof-of-direction)#32

Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
masterfrom
feat/xml-generic-mapping
Draft

feat(xml): generic namespace-aware mapping core (draft, proof-of-direction)#32
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
masterfrom
feat/xml-generic-mapping

Conversation

@irvingoujAtDevolution

Copy link
Copy Markdown
Collaborator

What this is

A small, additive first slice toward a generic, use-case-agnostic XML
(de)serializer in ironposh-xml with proper namespace support. It is a
draft to validate the direction — not the finished crate.

Why

Off-the-shelf namespace-aware XML serde (yaserde / instant-xml / quick-xml /
serde-roxmltree) was evaluated and didn't hold up — namespace handling is the
recurring failure. So we build on what already works: roxmltree (read) + the
forked Element builder (write).

The guiding boundary: ironposh-xml owns the mechanism, never the
vocabulary.
Concrete namespace URIs, tag names, and schema rules stay in
consumer crates (e.g. ironposh-winrm).

What's in the diff (2 files, ~190 lines incl. tests)

  • FromXml / ToXml — the mapping contract, one entry point each (no
    visit_node/visit_children/visit_attribute split).
  • NodeExt — the single matching primitive: element identity is the
    (namespace-URI, local-name) pair. The prefix is never compared.
  • A hand-written SoapBody impl — exactly the shape a future
    #[derive(FromXml, ToXml)] will generate (its expansion target).

The correctness proof (the part to review)

Tests assert the namespace invariant directly:

  • matches_regardless_of_prefixs:Body, soap:Body, and default-namespace
    Body all parse identically.
  • rejects_same_local_name_in_wrong_namespaceBody under the wrong URI is
    rejected.
  • child_in_wrong_namespace_is_ignoredAction under SOAP (not
    WS-Addressing) does not bind.
  • round_trips_through_to_xmlto_xml → serialize → re-parse → from_xml.

All 4 pass; the existing 42 ironposh-xml tests still pass.

Deliberately NOT in this PR

  • No proc macro yet (this validates the hand-written target first).
  • No removal of the existing XmlVisitor/XmlDeserialize (purely additive).
  • No XmlError slimming / roxmltree re-export cleanup.
  • ps_value / ComplexObject untouched — keeps its intermediate tree.

Question for review

Does the boundary + the (URI, local-name) matching primitive look correct
before I build the derive macro on top of it?

…Ext)

Adds the use-case-agnostic foundation for a generic XML (de)serializer:

- `FromXml` / `ToXml`: one-entry-point mapping traits (no visitor split).
- `NodeExt`: the single matching primitive — element identity is the
  `(namespace-URI, local-name)` pair; the prefix is never compared.

The crate ships only mechanism; concrete namespace URIs stay in consumers.
Hand-written `SoapBody` impl + tests prove the invariant: `s:` / `soap:` /
default-namespace encodings all match, wrong-namespace tags are rejected,
and it round-trips through `to_xml`. This impl is the expansion target a
future `#[derive(FromXml, ToXml)]` will generate.

Purely additive — existing XmlVisitor/XmlDeserialize and ps_value untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant