add default_namespace attribute

issue #45
This commit is contained in:
Marc-Antoine Arnaud
2020-02-24 14:47:18 +01:00
parent 389077e17c
commit dc79806128
5 changed files with 84 additions and 31 deletions

View File

@@ -161,6 +161,27 @@ fn ser_struct_default_namespace() {
convert_and_validate!(model, content);
}
#[test]
fn ser_struct_default_namespace_via_attribute() {
#[derive(YaSerialize, PartialEq, Debug)]
#[yaserde(
root = "tt",
default_namespace = "ttml",
namespace = "ttml: http://www.w3.org/ns/ttml",
namespace = "ttm: http://www.w3.org/ns/ttml#metadata"
)]
pub struct XmlStruct {
item: String,
}
let model = XmlStruct {
item: "something".to_string(),
};
let content = "<?xml version=\"1.0\" encoding=\"utf-8\"?><tt xmlns=\"http://www.w3.org/ns/ttml\" xmlns:ttm=\"http://www.w3.org/ns/ttml#metadata\"><item>something</item></tt>";
convert_and_validate!(model, content);
}
#[test]
fn de_struct_namespace_nested() {
#[derive(YaSerialize, Default, PartialEq, Debug)]