Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Relative Path

  1. #1
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts

    Relative Path

    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/stru...l#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?
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls

  • #2
    Regular Coder BoldUlysses's Avatar
    Join Date
    Jan 2008
    Location
    Winston-Salem, NC
    Posts
    938
    Thanks
    10
    Thanked 190 Times in 187 Posts
    Jerry, this post may help. It was in response to a lengthy post I wrote explaining the rules of the ../ method of declaring filepaths.
    matt | design | blog

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    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?
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #4
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    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.
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •