W3C

Testing XML Base Conformance

XML Core Working Group

13 December 2006

XML Base does not specify an interface for determining the base URI of a node in an XML document, but various other specifications directly or indirectly refer normatively to XML Base, and provide mechanisms by which the results of XML Base processing can be determined. Some of these specifications have test suites that include XML Base tests; for others the examples below can be adapted to serve as test cases.

Existing relevant specifications and resources

XLink 1.1
test collection
XSLT 2
fn:baseURI(), baseURI tests
DOM Level 3
baseURI property, Test collection, Tests (see files with names nodegetbaseuri01.xmlnodegetbaseuri20.xml).
Canonicalization 1.1
Forthcoming test collection

Discussion of a few key examples

  1. <elt xml:base="http://www.example.org/~Dürst/"/>

    The base URI of the element is http://www.example.org/~D%C3%BCrst/, but implementations should return it in the unescaped form http://www.example.org/~Dürst/.

  2. <outer xml:base="http://www.example.org/one/two"> <inner xml:base=""/> </outer>

    The base URI of the inner element is the same as that of the outer one: http://www.example.org/one/two. In effect, xml:base="" is a no-op.

  3. <elt xml:base="http://www.example.org/one/two#frag"/>

    The base URI of the element is http://www.example.org/one/two. This is because, according to RFC 3986, any fragment component is stripped before a URI reference is used as a base URI. Older implementations based on the first edition, which referenced RFC 2396, may include the fragment in the base URI. The difference is of no consequence as far as resource retrieval is concerned, because the fragment will be discarded when the base URI is used.

  4. <outer xml:base="http://www.example.org/one/two"> <inner xml:base="#frag"/> </outer>

    By the same reasoning as in example 3, the base URI of the inner element is the same as that of the outer one: http://www.example.org/one/two. Like xml:base="", xml:base="#frag" is a no-op.