Consider these two XML documents:
a.xml
<a xmlns="foo" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="b.xml" parse="xml" />
</a>
b.xml
<b>Hi Mom!</b>
What namespace should the <b> element be in after inclusion, foo or no namespace?
Using Nokogiri to load the first document with XInclude processing produces a text representation that would imply that <b> is in the parent namespace, but inspecting the elements claims that <b> has no namespace:
require 'nokogiri'
d = Nokogiri.XML(IO.read('a.xml'),&:xinclude)
puts d
#=> <?xml version="1.0"?>
#=> <a xmlns="foo" xmlns:xi="http://www.w3.org/2001/XInclude">
#=> <b>Hi Mom!</b>
#=> </a>
p d.root.namespace
#=> #<Nokogiri::XML::Namespace:0x3fd40c517de8 href="foo">
p d.root.elements.first.namespace
#=> nil
No namespace. XInclude operates at the infoset level and preserves the infoset properties of the included content. The infoset specification explicitly makes the point that
(my bold) – the
<b>element is not in a namespace, but its in-scope namespaces infoset property is no longer consistent with the namespace declarations in the “virtual” document that results from resolving the XInclude.