...

View Full Version : Relative Path



jerry62704
02-25-2009, 05:27 PM
I thought I knew how this worked. If you have "../" it moved up one level:

www.abc.com/xyz/w123/page.html
with
<a href="../somepage.htm.">
would refer to a page in xyz (parent to current directory).

Now I see W3c says:


First cite:
http://www.w3.org/TR/REC-html40/struct/links.html#idx-base_URI
In HTML, links and references to external images, applets, form-processing programs, style sheets, etc. are always specified by a URI. Relative URIs are resolved according to a base URI, which may come from a variety of sources. The BASE element allows authors to specify a document's base URI explicitly.

When present, the BASE element must appear in the HEAD section of an HTML document, before any element that refers to an external source. The path information specified by the BASE element only affects URIs in the document where the element appears.

For example, given the following BASE declaration and A declaration:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Our Products</TITLE>
<BASE href="http://www.aviary.com/products/intro.html">
</HEAD>

<BODY>
<P>Have you seen our <A href="../cages/birds.gif">Bird Cages</A>?
</BODY>
</HTML>

the relative URI "../cages/birds.gif" would resolve to:

http://www.aviary.com/cages/birds.gif




Second cite:
http://www.w3.org/TR/WD-html40-970917/htmlweb.html
5.1.2 Relative URLs

A relative URL (defined in [RFC1808]) doesn't contain any protocol or machine information. Its path generally refers to a resource on the same machine as the current document. Relative URLs may contain relative path components (".." means one level up in the hierarchy defined by the path), and may contain fragment identifiers.

Note the second cite says the same as what I thought, but the first says it goes up to the root, not the immediate parent.

What am I not seeing?

BoldUlysses
02-25-2009, 05:44 PM
Jerry, this post may help (http://www.codingforums.com/showpost.php?p=784167&postcount=9). It was in response to a lengthy post I wrote explaining the rules of the ../ method of declaring filepaths.

Rowsdower!
02-25-2009, 06:19 PM
Hey Jerry,

I think I see your confusion. Here's what I'm seeing:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Our Products</TITLE>
<BASE href="http://www.aviary.com/products/intro.html">
</HEAD>

<BODY>
<P>Have you seen our <A href="../cages/birds.gif">Bird Cages</A>?
</BODY>
</HTML>

the relative URI "../cages/birds.gif" would resolve to:

http://www.aviary.com/cages/birds.gif


We're starting out with the base url of http://www.aviary.com/products/intro.html, so when we introduce "../" to the filepath of a relative url we are just backing out of the "products" folder. In that case that puts us in the root directory, but that would not always be the case.

The phrase "resolved according to a base URI" doesn't mean that a relative url goes to the root. I think they just chose a somewhat unclear example to give. I think that they were just leaving the door open to introduce the possible use of the <base> tag and how it fits in with the relative filepath.

Does this make sense or have I misunderstood your question?

jerry62704
02-25-2009, 07:12 PM
What started all this is a page that has a <base> tag. Unfortunately, it is added by STRUTS. There is no end tag built by STRUTS even as the tag that calls STRUTS has one. The end results is the page won't validate.

I added a dummy "</base>" which made the validater happy, but the source code then gets an error in Eclipse (RAD7) that the added code is bogus. Damned if you do or if you don't. I started asking myself if I needed the <base> at all. In looking at the W3C writeup on it, I saw what I thought was a double jump "up" when I thought it should be a single (parent) jump up. Looking again, I can see 1) it is a single jump and 2) while I paid a lot of money for these eyes when I had them installed, they are getting older too.

I guess I'll try to eliminate it (<base>) for a few tests. Frankly, I don't see where it buys anything.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum