Question about xml:base

V

Victor Porton

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.
 
R

Richard Tobin

Victor Porton said:
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.
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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top