minidom: Rework Prefixes internal structure
Change the mapping in Prefixes to Prefix -> Namespace instead of Namespace -> Prefix. This allows us to not have duplicate prefixes anymore, but requires us to store the prefix on Element. This prefix is only taken as a hint anyway and used only when coming from the reader. This commits also partially removes the possibility to add prefixes when creating an Element via `Element::new`, `Element::builder` or `Element::bare`. Proper errors should be added in the following commits. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
429949102d
commit
1f2d7aa99d
4 changed files with 106 additions and 93 deletions
|
|
@ -145,7 +145,7 @@ fn writer_with_prefix() {
|
|||
.prefix(None, "ns2")
|
||||
.build();
|
||||
assert_eq!(String::from(&root),
|
||||
r#"<p1:root xmlns:p1="ns1" xmlns="ns2"/>"#,
|
||||
r#"<p1:root xmlns="ns2" xmlns:p1="ns1"/>"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ fn writer_with_prefix_deduplicate() {
|
|||
.append(child)
|
||||
.build();
|
||||
assert_eq!(String::from(&root),
|
||||
r#"<p1:root xmlns:p1="ns1" xmlns="ns2"><p1:child/></p1:root>"#,
|
||||
r#"<p1:root xmlns="ns2" xmlns:p1="ns1"><p1:child/></p1:root>"#,
|
||||
);
|
||||
|
||||
// Ensure descendants don't just reuse ancestors' prefixes that have been shadowed in between
|
||||
|
|
|
|||
Loading…
Reference in a new issue