-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I am trying to use xml_serde with attributes in namespaces, and I encounter a problem, with this code:
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Test {
#[serde(rename = "{domain}stuff")]
stuff: InnerTest,
}
#[derive(Debug, Serialize, Deserialize)]
struct InnerTest {
#[serde(rename = "$attr:{domain}a")]
pub attribute: i32,
#[serde(rename = "$value")]
pub value: String,
}
fn main() -> Result<()> {
let xml = xml_serde::to_string(&Test {
stuff: InnerTest {
attribute: 123,
value: "foobar".to_string(),
},
}).unwrap();
println!("{xml}");
let test: xml_serde::Result<Test> = xml_serde::from_string(xml);
println!("{test:?}");
Ok(())
}And it outputs:
<?xml version="1.0" encoding="UTF-8"?>
<stuff xmlns="domain" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="domain domain.xsd" a="123">foobar</stuff>
Err(Message("missing field `$attr:{domain}a`"))
So, serialization is ok, the generated xml is correct, but when deserializing the attribute, it seems that it has "forgotten" there was a default namespace, and it fails.
Metadata
Metadata
Assignees
Labels
No labels