minidom: breaking: Allow getting Element attributes by namespace
- Move Element.attributes to `AttrMap`, slowly using rxml's features and unrolling our own. - Add Element::attr_ns that requires the attribute namespace. Element:attr defaults to rxml::Namespace::none() but the interface changes nonetheless for a &NcNameStr. Similar changes on `ElementBuilder` methods. - Remove iterator structs for attributes, return a ref on the AttrMap directly as we don't need to keep attributes' internals hidden anymore. - Enable rxml's `macros` feature within tests to access the `xml_ncname` macro. Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
48f67d034e
commit
19865e5f1e
14 changed files with 272 additions and 236 deletions
|
|
@ -293,6 +293,7 @@ mod tests {
|
|||
use super::*;
|
||||
use jid::{BareJid, FullJid};
|
||||
use xso::error::FromElementError;
|
||||
use xso::exports::rxml;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
|
@ -602,25 +603,31 @@ mod tests {
|
|||
fn presence_with_to() {
|
||||
let presence = Presence::new(Type::None);
|
||||
let elem: Element = presence.into();
|
||||
assert_eq!(elem.attr("to"), None);
|
||||
assert_eq!(elem.attr(rxml::xml_ncname!("to")), None);
|
||||
|
||||
let presence = Presence::new(Type::None).with_to(Jid::new("localhost").unwrap());
|
||||
let elem: Element = presence.into();
|
||||
assert_eq!(elem.attr("to"), Some("localhost"));
|
||||
assert_eq!(elem.attr(rxml::xml_ncname!("to")), Some("localhost"));
|
||||
|
||||
let presence = Presence::new(Type::None).with_to(BareJid::new("localhost").unwrap());
|
||||
let elem: Element = presence.into();
|
||||
assert_eq!(elem.attr("to"), Some("localhost"));
|
||||
assert_eq!(elem.attr(rxml::xml_ncname!("to")), Some("localhost"));
|
||||
|
||||
let presence =
|
||||
Presence::new(Type::None).with_to(Jid::new("test@localhost/coucou").unwrap());
|
||||
let elem: Element = presence.into();
|
||||
assert_eq!(elem.attr("to"), Some("test@localhost/coucou"));
|
||||
assert_eq!(
|
||||
elem.attr(rxml::xml_ncname!("to")),
|
||||
Some("test@localhost/coucou")
|
||||
);
|
||||
|
||||
let presence =
|
||||
Presence::new(Type::None).with_to(FullJid::new("test@localhost/coucou").unwrap());
|
||||
let elem: Element = presence.into();
|
||||
assert_eq!(elem.attr("to"), Some("test@localhost/coucou"));
|
||||
assert_eq!(
|
||||
elem.attr(rxml::xml_ncname!("to")),
|
||||
Some("test@localhost/coucou")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue