Contextual base URLs

An issue arises when included material contains relative URL references, and originates from a different location to the document it is being copied into. It would appear that these references would adopt the base location of the destination document, and therefore become invalid. In order to avoid this problem, the XInclude application is expected to retain information on the original location of each merged fragment. This can be done by including XML Base attributes in the merged output file (see the previous chapter).

The XML Base standard can also be used to resolve relative URLs in the Href attribute of the Include element:

<book xml:base="file:///d:/book/" ... >
  ...
  <xi:include href="chapters/chapter1.xml" /> ... </book> ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.