xml: Add namespace prefixes

This commit is contained in:
Lennart
2024-12-31 19:07:37 +01:00
parent 09239dba7e
commit 5cacca9046
5 changed files with 47 additions and 18 deletions

View File

@@ -98,4 +98,5 @@ impl XmlDeserialize for Unparsed {
pub trait XmlRootTag {
fn root_tag() -> &'static [u8];
fn root_ns() -> Option<Namespace<'static>>;
fn root_ns_prefixes() -> HashMap<Namespace<'static>, &'static [u8]>;
}

View File

@@ -50,7 +50,7 @@ impl<T: XmlSerialize + XmlRootTag> XmlSerializeRoot for T {
&self,
writer: &mut quick_xml::Writer<W>,
) -> std::io::Result<()> {
let namespaces = HashMap::new();
let namespaces = Self::root_ns_prefixes();
self.serialize(Self::root_ns(), Some(Self::root_tag()), &namespaces, writer)
}
}