Subject: Specifying a file fragment in URI

From: Omer Zak <[email-masked]>
Date: Mon, 28 Jun 2004 22:47:32 +0300

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

---

From: Omer Zak <[email-masked]>
Date: Mon, 28 Jun 2004 22:55:02 +0300

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

---

From: "Nadav Har'El" <[email-masked]>
Date: Mon, 28 Jun 2004 22:58:30 +0300

> 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
[email-masked]             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Windows-2000/Professional isn't.
http://nadav.harel.org.il           |