Loading ...
Sorry, an error occurred while loading the content.

Specifying a file fragment in URI

Expand Messages
  • Omer Zak
    I am developing an application, which may need to refer to sections in text files. I would like to use URI to refer to the files. When a file is on local
    Message 1 of 5 , Jun 28, 2004
    • 0 Attachment
      I am developing an application, which may need to refer to sections in
      text files.
      I would like to use URI to refer to the files. When a file is on local
      disk, it is to be refered to (for example) as:

      file:///home/omerz/mysecretstuff.txt

      However, I want to refer to a section inside the file, where the section
      starts at character (or byte*) position N, and is M characters (or
      bytes*) long.
      If the file were HTML file, I would have been able to refer to anchors
      inside it (as in <a name="myanchor">...</a>) by means of the standard
      URI fragment specification such as:

      file:///home/omerz/mysecretstuff.txt#myanchor

      However, when the file in question is a text file, I do not have any
      anchors inside it, so I have to refer to a range of characters (or bytes*).
      One possible way is to use:

      file:///home/omerz/mysecretstuff.txt#b100.300

      which refers to 300-byte long fragment, which starts at 100th byte
      relative to start of file (where 1st byte in the file is 0).

      I googled in vain for any standard (official or de-facto) way to do this.
      So, before going forth and inventing my own specification, can any kind
      soul please direct me to the established way of doing this?

      *in UTF-8 encoding, a character may be more than one byte long, and be
      variable-length.
      Thanks,
      --- Omer
      My own blog is at http://www.livejournal.com/users/tddpirate/

      My opinions, as expressed in this E-mail message, are mine alone.
      They do not represent the official policy of any organization with which
      I may be affiliated in any way.
      WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
    • Omer Zak
      I tried again to google and found: http://dret.net/netdret/docs/draft-wilde-text-fragment-00.html It is exactly what I was looking for! ... My own blog is at
      Message 2 of 5 , Jun 28, 2004
      • 0 Attachment
        I tried again to google and found:

        http://dret.net/netdret/docs/draft-wilde-text-fragment-00.html

        It is exactly what I was looking for!

        Omer Zak wrote:
        > I googled in vain for any standard (official or de-facto) way to do this.
        > So, before going forth and inventing my own specification, can any kind
        > soul please direct me to the established way of doing this?
        >
        > *in UTF-8 encoding, a character may be more than one byte long, and be
        > variable-length.

        --- Omer
        My own blog is at http://www.livejournal.com/users/tddpirate/

        My opinions, as expressed in this E-mail message, are mine alone.
        They do not represent the official policy of any organization with which
        I may be affiliated in any way.
        WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
      • Arik Baratz
        ... [snip] ... I d like to comment. This part of the URI is parsed by the browser in case of a URL, so you might want to think of a way that will work with
        Message 3 of 5 , Jun 28, 2004
        • 0 Attachment
          > -----Original Message-----
          > From: Omer Zak [mailto:omerz@...]
          [snip]
          > I googled in vain for any standard (official or de-facto) way
          > to do this.
          > So, before going forth and inventing my own specification,
          > can any kind
          > soul please direct me to the established way of doing this?

          I'd like to comment. This part of the URI is parsed by the browser
          in case of a URL, so you might want to think of a way that will work
          with conventional browsers; The '#' example that you gave won't.

          What can work is a server-side script that will get the location as
          a parameter, convert the text to html (by wrapping it with <html>
          <body><pre> and </pre></body></html> and insert the anchor
          in html in the right location, like:

          http://host.name/doc.txt?loc=line123#anchor

          -- Arik
        • Nadav Har'El
          ... You should note that HTTP 1.1 already a way to get only a byte range from a file: search byte ranges in:
          Message 4 of 5 , Jun 28, 2004
          • 0 Attachment
            On Mon, Jun 28, 2004, Omer Zak wrote about "Found! (was: Re: [hackers-il] Specifying a file fragment in URI)":
            > I tried again to google and found:
            >
            > http://dret.net/netdret/docs/draft-wilde-text-fragment-00.html
            >
            > It is exactly what I was looking for!

            You should note that HTTP 1.1 already a way to get only a byte range from
            a file: search "byte ranges" in:

            http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

            It's not exactly what you wanted, but it's an efficient way to actually
            get just the byte range you're interested in, instead of getting all the
            file and then taking just a part of it. (of course, this only applies if
            you get files with HTTP; FTP has another method for getting a part of the
            file).


            --
            Nadav Har'El | Monday, Jun 28 2004, 10 Tammuz 5764
            nyh@... |-----------------------------------------
            Phone +972-523-790466, ICQ 13349191 |Windows-2000/Professional isn't.
            http://nadav.harel.org.il |
          • Tzahi Fadida
            Hi all, I am writing an academic research programm and I need an open source JAVA library or technique to plot an xy graph. There must be, however, an ability
            Message 5 of 5 , Jul 4, 2004
            • 0 Attachment
              Hi all,
              I am writing an academic research programm and I need an open source JAVA
              library or technique to plot an xy graph. There must be, however, an ability
              to plot thousands of points on the graph since I have a large data set.
              also, since the data is big, It must also have scrolling or zooming
              capability so we can visually local maximal points, etc...

              I would very much apperciate any help.
              10x.

              Regards,
              tzahi.
            Your message has been successfully submitted and would be delivered to recipients shortly.