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