From da536d072f2ce0c207c5a1e16a80a5f6ca2ae1e5 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 29 Nov 2022 11:52:26 +0100 Subject: [PATCH] Lookup prefixes from local scope --- instant-xml/src/de.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/instant-xml/src/de.rs b/instant-xml/src/de.rs index e8525f4..987ea94 100644 --- a/instant-xml/src/de.rs +++ b/instant-xml/src/de.rs @@ -134,9 +134,13 @@ impl<'xml> Context<'xml> { pub(crate) fn element_id(&self, element: &Element<'xml>) -> Result, 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(), },