njh/easyrdf — pull request #96 by scor (2012-12-18 17:04:57+00:00)
Title: add support for xmlns prefix (test 0183)

Looking in processNode() step 3, one can't execute any xpath on a DOMElement without re-creating a DOMDocument which would require parsing each DOMElement. SimpleXML does offer getDocNamespaces() but I tried importing the DOMElement into SimpleXML via dom_import_simplexml() but that discarded the xmlns definition. We could parse each DOMElement::C14N() with SimpleXML but that would impact the performance of the parser. Instead I run simplexml_import_dom() once in parse(), and that's no extra parsing since the DOMDocument is imported in SimpleXML. Then I store the namespaces in context['xmlns']. In Step 3 of processNode(), I loop through all defined xmlns prefixes to see if they are defined. Documents which don't use xmlns will see no performance impact since this loop will never be executed.