W3C Logo

XML Base (XBase)

W3C Working Draft 20-December-1999

This version:
http://www.w3.org/TR/1999/WD-xmlbase-19991220
Latest version:
http://www.w3.org/TR/xmlbase
Editors:
Jonathan Marsh (Microsoft) <jmarsh@microsoft.com>

Abstract

This document proposes syntax for providing the equivalent of HTML BASE functionality generically in XML documents by defining an XML attribute named xml:base.

Status of this document

The XML Linking Working Group, with this 20 December 1999 first XBase working draft, invites comment on this specification.

The W3C XML Activity believes that a facility of this type is needed soon by a wide variety of XML applications within the W3C and outside.

The W3C Membership and other interested parties are invited to review the specification and report early implementation experience. The purpose of publishing this draft is to solicit feedback from the community both on the need for such a facility and the suitability of the mechanism.

Comments on this document should be sent to the public mailing list www-xml-linking-comments@w3.org (archive). While we welcome implementation experience reports, the XML Linking Working Group will not allow early implementation to constrain its ability to make changes to this specification prior to final release.

For background on this work, please see the XML Activity Statement.

Table of Contents

1. Introduction
2. xml:base Attribute
3. Resolving Relative URIs
4. Relation to XML Information Set
5. Impacts on Other Standards

Appendices

A. References
B. Issues List

1. Introduction

The XML Linking Language [XLink] defines XML constructs to describe links between resources. One of the stated requirements on XLink is to support HTML 4.0 [HTML40] linking constructs in a generic way. The HTML BASE element is one such construct which the XLink Working Group has considered. BASE allows authors to explicitly specify a document's base URI for the purpose of resolving relative URIs in links to external images, applets, form-processing programs, style sheets, and so on.

This document proposes that the functionality of BASE be provided to generic XML applications. Furthermore it proposes that the resolution of relative URIs is not limited to the domain of XLink but is applicable to any XML application that makes use of relative URIs. In other words, this problem should be solved at the addressing (URI) level and not at the higher level of linking (XLink).

This document introduces a syntax for a generic BASE functionality in XML documents by defining an xml:base attribute.

2. xml:base Attribute

The attribute xml:base may be inserted in XML documents to specify a base URI other than the base URI of the document or external entity, which is normally used to resolve relative URIs. The value of this attribute is interpreted as a URI as defined in RFC 2396 [RFC2396].

The base URI specified by xml:base sets the base URI information set property of the element on which this attribute occurs, and to its descendants except where further xml:base attributes are applied. The value of the xml:base attribute may itself be a relative URI, in which case it must itself be resolved against the base URI of the element it appears on. This base URI may have been obtained from an xml:base attribute on an ancestor element. This enables scoping behavior consistent with the xml:lang and xml:space attributes.

In namespace-aware XML processors, the "xml" prefix is bound to the namespace name http://www.w3.org/XML/1998/namespace as described in XML Namespaces [XML Names]. Note that xml:base can be still used by non-namespace-aware processors.

NOTE: Warning to Implementors: Placing the base attribute in the xml namespace does not leave any room for namespace versioning before this specification becomes a recommendation. Implementors may want to use a different namespace for their prototypes, such as the URI of this Working Draft, until this specification is recognized to be stable.

An example of xml:base in a simple XHTML document follows.

<?xml version="1.0"?>
<html xmlns="http://www.w3.org/TR/xhtml1/strict"
      xml:base="http://somewhere.org">
  <head>
    <title>Virtual Library</title>
  </head>
  <body>
    <p>See <a href="new.xml">what's new</a>!</p>
    <p>Check out the hot picks of the day!</p>
    <ol xml:base="/hotpicks">
      <li><a href="pick1.xml">Hot Pick #1</a></li>
      <li><a href="pick2.xml">Hot Pick #2</a></li>
      <li><a href="pick3.xml">Hot Pick #3</a></li>
    </ol>
  </body>
</html>

In URIs in this example resolve to full URIs thus:

3. Resolving Relative URIs

Applications resolving URIs appearing in XML documents should resolve these URIs relative to the base URI as described in RFC 2396 [RFC2396]. The following describes specifically how RFC 2396 applies to XML documents containing xml:base.

The base URI is calculated according to the following precedences (highest priority to lowest):

  1. The base URI is determined by the scope of xml:base attributes in the XML.
  2. The base URI is that of the encapsulating entity, which is defined by XML 1.0 [XML] to be the URI of the document entity, the entity containing the external DTD subset, or other external parameter entity.
  3. The base URI is that of the URI used to retrieve the entity.
  4. The base URI = "" (undefined).
NOTE: Steps 2-4 above are a summary of the current behavior of XML 1.0 and the XML Infoset. Step 1 is described in this specification.

If the base URI is undefined, the URIs are considered erroneous.

Ed. note: What does "erroneous" imply? I just copied it from the HTML spec...

Note that the scope of xml:base does not extend into external entities. This is in keeping with xml:space.

4. Relation to XML Information Set

The XML Information Set [XML Infoset] exposes an optional base URI property, which currently is not affected by the presence of xml:base attributes. This document specifies an addition to the XML Information Set which integrates the base URI information set property and the xml:base attribute. This ensures that applications that rely on the xml:base attribute and those that rely on mechanisms which surface the base URI information set property produce the same results.

NOTE: It is this level of integration with XML 1.0 and the Infoset that drives the desire to use the "xml" namespace.

The value of the optional base URI property on document information items is not affected by xml:base.

The value of the optional base URI property on element information items and processing instructions is determined by the rules for resolving relative URIs given above.

In addition to the base URI property, the Infoset should continue to expose xml:base as an attribute.

5. Impacts on Other Standards


Appendices

A. References

HTML40
World Wide Web Consortium. HTML 4.0 Specification. W3C Recommendation. See: http://www.w3.org/TR/REC-html40.
RFC2396
IETF (Internet Engineering Task Force). RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax IETF RFC. See http://www.ics.uci.edu/pub/ietf/uri/rfc2396.txt.
XHTML
World Wide Web Consortium. XHTML? 1.0: The Extensible HyperText Markup Language. W3C Working Draft. See http://www.w3.org/TR/xhtml1
XLink
World Wide Web Consortium. XML Linking Language (XLink). W3C Working Draft. See http://www.w3.org/TR/xlink.
XML
World Wide Web Consortium. Extensible Markup Language (XML) 1.0. W3C Recommendation. See http://www.w3.org/TR/1998/REC-xml-19980210
XML Datatypes
World Wide Web Consortium. XML Schema Part 2: Datatypes. W3C Working Draft. See http://www.w3.org/TR/xmlschema-2
XML Infoset
World Wide Web Consortium. XML Information Set. W3C Working Draft. See http://www.w3.org/TR/xml-infoset
XML Names
World Wide Web Consortium. Namespaces in XML. W3C Recommendation. See http://www.w3.org/TR/REC-xml-names

B. Issues List

xmlbase:system-identifiers
xmlbase:namespaces-compatibility