Background

The URL standard includes the concept of 'relative' URL references (see Chapter 30 for details). With such references, it is necessary to determine a starting point, or 'base' location, from which to follow the URL path to the required resource. By default, the starting point is the directory containing the document that includes the URL reference. While useful, this assumption can be too limiting. If the document is moved to a new location, but the related resources are not, the URL reference becomes broken. When many references are involved, it can be a considerable editing task to fix them all.

A better solution would be to enable the base location to be changed, within the document, in order to fix all of the broken references. This is one of the purposes of the XML Base standard. Its other purposes are to allow relative URLs to be used more frequently, by re-setting the base location, perhaps several times within the same document, and to drill down further into an existing location, so that the relative paths in the URL references can be made shorter.

The XLink standard (see Chapter 27) relies upon the XML Base standard. Indeed, the idea for the XML Base standard emerged from a need for this feature within the XLink standard.

However, other standards, such as the XInclude standard (see the next chapter), are beginning to refer to XML Base too, thus justifying the decision to make it a separate standard.

Relative URLs

Normally, all relative URL references in a document assume that the location of the document is the starting point for calculating the target resource location. For example, consider a document called 'maindoc.xml' that is currently situated in the 'books' directory on the 'D:' drive:

						d:/books/maindoc.xml

If there is a relative URL reference in this document that only contains the name of another file, this file will be assumed to be in the same directory. A slightly more complex relative URL, such as 'fiction/1984.xml', would be resolved as follows:

						d:/books/maindoc.xml
         fiction/1984.xml
					



New base location

XML Base is used to set the base address to a new location, such as 'file:///d:/newbooks', and the relative URLs are then updated to start from this location.

The example above would be re-located as follows:

d:/books/maindoc.xml

d:/newbooks/fiction/1984.xml



It is even possible for the base address to be re-set a number of times within the same document, and the document hierarchy is exploited to give each definition a specific scope.

Also note that the characters allowed in this value must conform to the constraints of the URL standard (see Chapter 30).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.182.45