import { XMLElement , DEFAULT_NS } from "@xml-tools/ast" ; export function resolveXMLNS ( xmlElement ) { return resolveXMLNSFromPrefix ( xmlElement . ns , xmlElement ) ; } export function resolveXMLNSFromPrefix ( prefix , xmlElement ) { const prefixXmlns = prefix ?? DEFAULT_NS ; const resolvedXmlns = xmlElement . namespaces [ prefixXmlns ] ; return resolvedXmlns ; } export function isSameXMLNS ( xmlElement1 , xmlElement2 ) { return isSameXMLNSFromPrefix ( xmlElement1 . ns , xmlElement1 , xmlElement2 . ns , xmlElement2 ) ; } export function isSameXMLNSFromPrefix ( prefix1 , xmlElement1 , prefix2 , xmlElement2 ) { const ns1 = resolveXMLNSFromPrefix ( prefix1 , xmlElement1 ) ; const ns2 = resolveXMLNSFromPrefix ( prefix2 , xmlElement2 ) ; if ( ns1 === ns2 && ns1 !== undefined ) { return true ; } if ( ns1 === undefined && ns2 === undefined && prefix1 === prefix2 ) { return true ; } return false ; }