[whatwg] <base> versus xml:base
Martin Atkins
mart at degeneration.co.uk
Wed Mar 14 13:37:20 PDT 2007
Asbjørn Ulsberg wrote:
>
>> If it is, then when looking at links inside head, relative URIs are
>> resolved using a base of "bar/foo/bar/" (taking head at xml:base into
>> account twice: once to resolve base at href, which sets the document's
>> base URI, and then relative to that base URI to resolve link at href's).
>
> Hm, that sounds weird. I'd say once base at href is resolved (taking into
> account the parent xml:base URI), then that's final. Any xml:base's after
> <base>'s presence will override the base, but I don't see a reason for
> applying xml:base twice. Since <base> is a special case element that
> magically affects all URI's in the document, I'd say it works like that
> even when combined with 'xml:base'.
>
This kinda-cyclic definition is caused by the fact that the "base"
element is defined as actually setting a property of the document as a
whole.
So let's imagine that there's in illusionary element enclosing the whole
document, so that we can write this in terms of xml:base...
So if we imagine that we've retrieved a document from http://example.com/:
<(document) xml:base="http://example.com/">
<html>
<head xml:base="foo/">
<link href="bar.html" />
</head>
...
</html>
</(document)>
So here, that link ends up being http://example.com/foo/bar.html,
because the xml:base on "head" is relative to the xml:base on the document.
Now if we throw in an HTML "base" element:
<(document) xml:base="???">
<html>
<head xml:base="foo/">
<base href="wibble/" />
<link href="bar.html" />
</head>
...
</html>
</(document)>
What is the document's xml:base set to now?
the "base" element overrides the original document URL, making it
http://example.com/foo/wibble/, but since the xml:base on the document
is now http://example.com/foo/wibble/, the base href is now
http://example.com/foo/wibble/foo/wibble/ and so on ad infinitum.
So it seems to me that base href has to be a special case of some sort.
I'm not sure what the special case should be. I think in this case I'd
expect the notional xml:base on the document to be
http://www.example.com/wibble/ and the URL in my "link" element to end
up as http://www.example.com/wibble/foo/bar.html ... in other words, the
base href has ignored xml:base entirely... the base href attribute is in
effect acting as if it were the xml:base attribute on my imaginary
"(document)" element, regardless of its actual position in the DOM.
More information about the whatwg
mailing list