Discussion:
Question about xml:base
(too old to reply)
Victor Porton
2004-05-31 12:13:15 UTC
Permalink
What can be and what should be xml:base attribute?
Should/can it end with a slash? What to do if it
doesn't end with a slash?

If xml:base="http://xxx.org/aaa/" anything is clear.
But what if xml:base="http://yyy.org/bbb"? Does now
href="a.html" mean http://yyy.org/bbb/a.html or
http://yyy.org/a.html?

As I read the RFC2396 the base URL of
http://zzz.org/a.html is by default http://zzz.org/a.html
what really point to http://zzz.org/.
Then base URL of http://yyy.org/bbb should really point
to http://yyy.org/? I'm messed.
Richard Tobin
2004-05-31 13:48:05 UTC
Permalink
Post by Victor Porton
What can be and what should be xml:base attribute?
It should be the base URI that you want to use for resolving relative URIs
in the document.

Normally the base URI is the URI of the document itself. However,
only the "directory" part of it is relevant for resolving relative
URIs, so it doesn't really matter what appears after the last slash of
the path part.
Post by Victor Porton
Should/can it end with a slash? What to do if it
doesn't end with a slash?
When resolving relative URIs, the part after the last slash of the
path part is removed and replaced with the relative URI. So these are
the effectively the same:

http://example.org/foo/bar/baz
http://example.org/foo/bar/

and are different from

http://example.org/foo/bar

If you use them to resolve "one/two" you will get

http://example.org/foo/bar/one/two

in the first two cases, and

http://example.org/foo/one/two

in the third.
Post by Victor Porton
If xml:base="http://xxx.org/aaa/" anything is clear.
But what if xml:base="http://yyy.org/bbb"? Does now
href="a.html" mean http://yyy.org/bbb/a.html or
http://yyy.org/a.html?
The latter.

(By the way, if you use your web browser to fetch a directory without
putting the slash on the end, the server sends a redirect to the name
with a slash added, so that relative URIs will work. In most web
browsers you can see the slash appear after you hit return.)

-- Richard

Loading...