Skip to main content

get_foreign_node_qname

Function get_foreign_node_qname 

Source
pub fn get_foreign_node_qname(node: &Node) -> SymStr
Expand description

get_node_qname for a node read out of a FOREIGN document — a tree parsed by crate::common::xml::parse_fragment rather than built by us. Used by Document::append_tree, the one place such a tree is ever walked.

The difference is confined to the DEFAULT-namespace case. Perl’s single Model::getNodeQName always maps a namespace URI to its registered code prefix (Common/Model.pmgetNamespacePrefix), which is what gives RegisterNamespace (Package.pm:2049) its effect on absorbed content: an xhtml snippet arrives as <p xmlns="…/1999/xhtml">, i.e. an EMPTY libxml prefix over a non-ltx URI, and must be re-created as xhtml:p. Mislabelling it ltx:p would strip exactly the namespace the XHTML post-processor keys on (copy-foreign matches xhtml:*), silently dropping the raw HTML.

Splitting that off from get_node_qname is a pure PERFORMANCE factoring with no behavioural difference, because inside our own document an element either sits in the ltx default namespace or carries an explicit code prefix — the re-created xhtml:p above included. So only a foreign tree can present the ambiguous shape, and reading the URI on the shared path would cost every other caller a String allocation per node (measured: 3.4%).