You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Roundtripping a xml:lang attribute on an element is not possible.
Example:
#[derive(Debug,PartialEq,Deserialize,Serialize)]structElementWithXmlLang{#[serde(rename = "$text")]body:&'staticstr,#[serde(rename = "@xml:lang")]lang:&'staticstr,}// ...serialize_as!(xml_lang_attribute:ElementWithXmlLang{ body:"Ikke for sarte sjæle", lang:"da"}
=> "<root xml:lang=\"da\">Ikke for sarte sjæle</root>");
This serializes correctly, but fail to deserialize (deserialization roundtrip: Custom("missing field '@xml:lang'")), since the element has its 'xml' prefix stripped by the key handling inside key.rs (QNameDeserializer::from_attr), likely introduced when adressing #537.
Since the namespace handling is incomplete anyways (see my suggestions in #218), it would make sense to allow the 'xml' namespace to pass through so the example above could roundtrip.
Using #[serde(rename = "@lang")] works for deserializing, but is not desirable, since it allows unqualified names to go through, too.
The text was updated successfully, but these errors were encountered:
jespersm
added a commit
to jespersm/quick-xml
that referenced
this issue
Jan 18, 2025
Roundtripping a
xml:lang
attribute on an element is not possible.Example:
This serializes correctly, but fail to deserialize (
deserialization roundtrip: Custom("missing field '@xml:lang'")
), since the element has its 'xml' prefix stripped by the key handling insidekey.rs
(QNameDeserializer::from_attr
), likely introduced when adressing #537.Since the namespace handling is incomplete anyways (see my suggestions in #218), it would make sense to allow the 'xml' namespace to pass through so the example above could roundtrip.
Using
#[serde(rename = "@lang")]
works for deserializing, but is not desirable, since it allows unqualified names to go through, too.The text was updated successfully, but these errors were encountered: