Question

The following are URIs. But which ones are URLs? Which ones are URNs?

ftp://ftp.is.co.za/rfc/rfc1808.txt
http://www.ietf.org/rfc/rfc2396.txt
ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:John.Doe@example.com
news:comp.infosystems.www.servers.unix
tel:+1-816-555-1212
telnet://192.0.2.16:80/
urn:oasis:names:specification:docbook:dtd:xml:4.1.2
Was it helpful?

Solution

From RFC 3986 §1.1.3:

The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location"). The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme [RFC2141], which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.

The precise distinction is contained within RFC 3305 §2, and can be summarised [translated?] as follows.

Uniform Resource Identifier (URI)

A URI is anything matching the syntax described in RFC 3986 Appendix A; it identifies some sort of resource. The resource in question can be anything from a webpage to a telephone number to a street address to some JavaScript to a GUID, disambiguated by the scheme at the start of the URI (the part before the first :).

As you noted, all of your samples are URIs.

Uniform Resource Locator (URL)

A URL is a URI that also tells you how to access whatever resource it's describing. This is a very informal concept (see RFC 3305 §2.2), and as such is difficult to define with any certainty. (It should be noted that, in my experience, most members of the public say URL when they mean URI.)

All except the last of your samples is probably a URL. (The distinction cannot be made for certain; as above, URL is informal.) For more on why the last one isn't, keep reading,

Uniform Resource Name (URN)

A URN, as defined by RFC 1737 and RFC 2141, is a way of giving a more-or-less permanent name to something. It has the syntax

urn:<namespace>:<more :-separated parts>

where the urn: is the scheme name (so a processor knows it's a URN), the <namespace> is a way of telling apart [basically] different peoples' URNs, and the rest of the URN [more :-separated text] identifies something within that namespace. RFC 1737 §2 mandates that a URN always points to exactly the same thing forever. It also requires that URNs which have corresponding URLs must have some way to be translated into that URL; this would seem to imply that a URN is not a URL.

Your last sample (urn:oasis:names:specification:docbook:dtd:xml:4.1.2) is of the urn scheme; it is, by definition, a URN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top