Map default xml prefix

This commit is contained in:
Nicholas Rempel 2024-04-03 22:19:16 -07:00 committed by Dirkjan Ochtman
parent 2b691c5131
commit a199cc7b5c
2 changed files with 13 additions and 0 deletions

View File

@ -185,6 +185,13 @@ impl<'xml> Context<'xml> {
} }
fn lookup(&self, prefix: &str) -> Option<&'xml str> { fn lookup(&self, prefix: &str) -> Option<&'xml str> {
// The prefix xml is by definition bound to the namespace
// name http://www.w3.org/XML/1998/namespace
// See https://www.w3.org/TR/xml-names/#ns-decl
if prefix == "xml" {
return Some("http://www.w3.org/XML/1998/namespace");
}
self.stack self.stack
.iter() .iter()
.rev() .rev()

View File

@ -34,6 +34,12 @@ fn default_namespaces() {
Ok(NestedDe { flag: true }) Ok(NestedDe { flag: true })
); );
// Default namespace not-nested - with xml:lang
assert_eq!(
from_str("<NestedDe xml:lang=\"en\" xmlns=\"URI\" xmlns:bar=\"BAZ\"><bar:flag>true</bar:flag></NestedDe>"),
Ok(NestedDe { flag: true })
);
// Default namespace not-nested - wrong namespace // Default namespace not-nested - wrong namespace
assert_eq!( assert_eq!(
from_str( from_str(