mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 17:38:22 +00:00
TagList: Correctly write namespace
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
use derive_more::derive::From;
|
use derive_more::derive::From;
|
||||||
use quick_xml::{
|
use quick_xml::name::Namespace;
|
||||||
events::{BytesStart, Event},
|
|
||||||
name::Namespace,
|
|
||||||
};
|
|
||||||
use rustical_xml::{NamespaceOwned, XmlSerialize};
|
use rustical_xml::{NamespaceOwned, XmlSerialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@@ -12,13 +9,17 @@ pub struct TagList(Vec<(Option<NamespaceOwned>, String)>);
|
|||||||
impl XmlSerialize for TagList {
|
impl XmlSerialize for TagList {
|
||||||
fn serialize<W: std::io::Write>(
|
fn serialize<W: std::io::Write>(
|
||||||
&self,
|
&self,
|
||||||
ns: Option<Namespace>,
|
_ns: Option<Namespace>,
|
||||||
tag: Option<&[u8]>,
|
_tag: Option<&[u8]>,
|
||||||
namespaces: &HashMap<Namespace, &[u8]>,
|
_namespaces: &HashMap<Namespace, &[u8]>,
|
||||||
writer: &mut quick_xml::Writer<W>,
|
writer: &mut quick_xml::Writer<W>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
for (_ns, tag) in &self.0 {
|
for (ns, tag) in &self.0 {
|
||||||
writer.write_event(Event::Empty(BytesStart::new(tag)))?;
|
let mut el = writer.create_element(tag);
|
||||||
|
if let Some(ns) = ns {
|
||||||
|
el = el.with_attribute(("xmlns", String::from_utf8_lossy(&ns.0)));
|
||||||
|
}
|
||||||
|
el.write_empty()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user