Lookup prefixes from local scope

This commit is contained in:
Dirkjan Ochtman 2022-11-29 11:52:26 +01:00
parent 8233884207
commit da536d072f
1 changed files with 7 additions and 3 deletions

View File

@ -134,9 +134,13 @@ impl<'xml> Context<'xml> {
pub(crate) fn element_id(&self, element: &Element<'xml>) -> Result<Id<'xml>, Error> {
Ok(Id {
ns: match (element.default_ns, element.prefix) {
(_, Some(prefix)) => self
.lookup(prefix)
.ok_or_else(|| Error::UnknownPrefix(prefix.to_owned()))?,
(_, Some(prefix)) => match element.level.prefixes.get(prefix) {
Some(ns) => *ns,
None => match self.lookup(prefix) {
Some(ns) => ns,
None => return Err(Error::UnknownPrefix(prefix.to_owned())),
},
},
(Some(ns), None) => ns,
(None, None) => self.default_ns(),
},