xso-proc: add support for built-in prefixes in attribute names

This simplifies the use of built-in XML attributes such as xml:lang.
This commit is contained in:
Jonas Schäfer 2024-06-24 07:43:51 +02:00
commit d4d520e1f6
3 changed files with 104 additions and 9 deletions

View file

@ -282,3 +282,20 @@ fn namespaced_attribute_roundtrip_b() {
xmlns:tns1='urn:example:ns2' tns1:foo='a2'/>",
);
}
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
#[xml(namespace = NS1, name = "attr")]
struct PrefixedAttribute {
#[xml(attribute = "xml:lang")]
lang: String,
}
#[test]
fn prefixed_attribute_roundtrip() {
#[allow(unused_imports)]
use std::{
option::Option::{None, Some},
result::Result::{Err, Ok},
};
roundtrip_full::<PrefixedAttribute>("<attr xmlns='urn:example:ns1' xml:lang='foo'/>");
}