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
|
|
@ -35,6 +35,7 @@ mod tests {
|
|||
use crate::ns;
|
||||
use minidom::Element;
|
||||
use xso::error::{Error, FromElementError};
|
||||
use xso::exports::rxml;
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
|
|
@ -80,13 +81,13 @@ mod tests {
|
|||
let receipt = Request;
|
||||
let elem: Element = receipt.into();
|
||||
assert!(elem.is("request", ns::RECEIPTS));
|
||||
assert_eq!(elem.attrs().count(), 0);
|
||||
assert_eq!(elem.attrs().into_iter().count(), 0);
|
||||
|
||||
let receipt = Received {
|
||||
id: String::from("coucou"),
|
||||
};
|
||||
let elem: Element = receipt.into();
|
||||
assert!(elem.is("received", ns::RECEIPTS));
|
||||
assert_eq!(elem.attr("id"), Some("coucou"));
|
||||
assert_eq!(elem.attr(rxml::xml_ncname!("id")), Some("coucou"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue