Merge branch 'Eijebong/minidom-rs-fix_namespaced_attributes'

# Conflicts:
#	src/tests.rs
This commit is contained in:
lumi 2017-04-26 01:02:17 +02:00
commit c6f9cc485f
2 changed files with 30 additions and 3 deletions

View file

@ -7,11 +7,12 @@ use xml::writer::EventWriter;
use element::Element;
const TEST_STRING: &'static str = r#"<?xml version="1.0" encoding="utf-8"?><root xmlns="root_ns" a="b">meow<child c="d" /><child xmlns="child_ns" d="e" />nya</root>"#;
const TEST_STRING: &'static str = r#"<?xml version="1.0" encoding="utf-8"?><root xmlns="root_ns" xml:lang="en" a="b">meow<child c="d" /><child xmlns="child_ns" d="e" xml:lang="fr" />nya</root>"#;
fn build_test_tree() -> Element {
let mut root = Element::builder("root")
.ns("root_ns")
.attr("xml:lang", "en")
.attr("a", "b")
.build();
root.append_text_node("meow");
@ -22,6 +23,7 @@ fn build_test_tree() -> Element {
let other_child = Element::builder("child")
.ns("child_ns")
.attr("d", "e")
.attr("xml:lang", "fr")
.build();
root.append_child(other_child);
root.append_text_node("nya");
@ -105,3 +107,11 @@ fn two_elements_with_same_arguments_different_order_are_equal() {
let elem2: Element = "<a c='d' b='a'/>".parse().unwrap();
assert_ne!(elem1, elem2);
}
#[test]
fn namespace_attributes_works() {
let mut reader = EventReader::new(Cursor::new(TEST_STRING));
let root = Element::from_reader(&mut reader).unwrap();
assert_eq!("en", root.attr("xml:lang").unwrap());
assert_eq!("fr", root.get_child("child", "child_ns").unwrap().attr("xml:lang").unwrap());
}