[DAS2] hrefs and xml:base

Andrew Dalke dalke at dalkescientific.com
Tue May 10 08:46:20 UTC 2005

> As far as I can tell, there is no restriction that an xml:base URI
> must end with a /, but that seems to be the convention.
> In this case, constructing relative URLs by concatenating ../ onto
> the xml:base URI should work.

If the URI doesn't end with a '/' then the last term will almost
certainly be removed as part of the join.  That is

   xml:base = "http://www.biodas.org/some/path/foo"

   id = "bar"

should generate

   xml:base = "http://www.biodas.org/some/path/bar"

Except for an empty id that last term ("foo") is needless.

> I did find an example of an xml:base that points to a
> file, but it’s on a
> MSDN site, making it therefore highly suspect:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ 
> dnxmlnet/html/xinclude.asp

There's no problem having xml:base point to a file.

> BTW, the W3C recommendation http://www.w3.org/TR/xmlbase/
> doesn't mention the use of ../ within an XML base spec.

What it does is refer people to RFC 2396 for a description
of how a base and relative URI interact.  See section
5.2 of that spec for details.

That RFC is document format independent.  The xml:base
spec describes how xml:base works in an XML document.

   The base URI of an element is:

      the base URI specified by an xml:base attribute on the element,
        if one exists, otherwise
      the base URI of the element's parent element within the document
        or external entity, if one exists, otherwise
      the base URI of the document entity or external entity containing
        the element.

That's a recursive definition, so multiple xml:bases
are allowed.

Once the base and relative URI's are known, they are
joined as defined in RFC 2396.  Though I see now it's
out of date.

> But since it's just a URI, it is allowed. See the URI spec:
> http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#path

RFC 3986 obsoletes the RFC 2396 mentioned in the xml:base
spec.   :)

					dalke at dalkescientific.com

More information about the DAS2 mailing list