feat(xml): generic namespace-aware mapping core (draft, proof-of-direction)#32
Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
Draft
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A small, additive first slice toward a generic, use-case-agnostic XML
(de)serializer in
ironposh-xmlwith proper namespace support. It is adraft 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
Elementbuilder (write).The guiding boundary:
ironposh-xmlowns the mechanism, never thevocabulary. 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 (novisit_node/visit_children/visit_attributesplit).NodeExt— the single matching primitive: element identity is the(namespace-URI, local-name)pair. The prefix is never compared.SoapBodyimpl — 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_prefix—s:Body,soap:Body, and default-namespaceBodyall parse identically.rejects_same_local_name_in_wrong_namespace—Bodyunder the wrong URI isrejected.
child_in_wrong_namespace_is_ignored—Actionunder SOAP (notWS-Addressing) does not bind.
round_trips_through_to_xml—to_xml→ serialize → re-parse →from_xml.All 4 pass; the existing 42 ironposh-xml tests still pass.
Deliberately NOT in this PR
XmlVisitor/XmlDeserialize(purely additive).XmlErrorslimming / roxmltree re-export cleanup.ps_value/ComplexObjectuntouched — keeps its intermediate tree.Question for review
Does the boundary + the
(URI, local-name)matching primitive look correctbefore I build the derive macro on top of it?