Skip to content

Comments

Restore ability to deserialize attributes that represents XML namespace mappings (xmlns:xxx)#539

Merged
dralley merged 1 commit intotafia:masterfrom
Mingun:de-ns-binding
Jan 6, 2023
Merged

Restore ability to deserialize attributes that represents XML namespace mappings (xmlns:xxx)#539
dralley merged 1 commit intotafia:masterfrom
Mingun:de-ns-binding

Conversation

@Mingun
Copy link
Collaborator

@Mingun Mingun commented Jan 6, 2023

Fixes #537.

Change in behavior was made in 8b50c64 of #490

quick-xml/src/de/key.rs

Lines 73 to 80 in 4a09041

/// Creates deserializer from name of an attribute
pub fn from_attr(name: QName<'d>, decoder: Decoder) -> Result<Self, DeError> {
let local = decode_name(name, decoder)?;
Ok(Self {
name: Cow::Owned(format!("@{local}")),
})
}

Here only local part of an attribute name is mapped to the field name. Because xmlns:... attributes is a special names, I make a special handling for that names -- use the full name of an attribute.

Note, that usually xmlns should not be considered as a data that could be accessed via serde interface. This is metadata of an XML serialization format. When (if) #218 would be implemented, that attributes most likely wouldn't be accessible at all.

@Mingun Mingun added serde Issues related to mapping from Rust types to XML namespaces Issues related to namespaces support labels Jan 6, 2023
@Mingun Mingun requested a review from dralley January 6, 2023 18:12
@dralley dralley merged commit 967d60d into tafia:master Jan 6, 2023
@Mingun Mingun deleted the de-ns-binding branch January 6, 2023 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

namespaces Issues related to namespaces support serde Issues related to mapping from Rust types to XML

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serialize to String works, but Deserialize from that same String fails on version 0.27.1

2 participants