DomNode
interface that exposes this information.
However, unlike the DomNode::getNamespaceURI()
attribute, the DomNode::getBaseURI()
attribute is not a static piece of information that every node carries. Instead, it is a value that is dynamically computed according to [XML Base]. This means its value depends on the location of the node in the tree and moving the node from one place to another in the tree may affect its value. Other changes, such as adding or changing an xml:base attribute on the node being queried or one of its ancestors may also affect its value.
One consequence of this it that when external entity references are expanded while building a DomDocument
one may need to add, or change, an xml:base attribute to the DomElement
nodes originally contained in the entity being expanded so that the DomNode::getBaseURI()
returns the correct value. In the case of DomProcessingInstruction
nodes originally contained in the entity being expanded the information is lost. [DOM Level 3 Load and Save] handles elements as described here and generates a warning in the latter case.