This RFC provides the means for embedding base URIs in documents.
There are rules for determining the base URI:
The base URI is embedded in the document's content.
The base URI is that of the encapsulating entity (message, document, or none).
The base URI is the URI used to retrieve the entity.
The base URI is defined by the context of the application.
There is a W3C Recommendation called XML Base that covers (1).