Question about xml:base

Victor Porton

Usenet Archive
Joined
May 31, 2004
Messages
18
Reaction score
0
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

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
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

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top