URI, URL and URN

The note Resources and URIs introduced the foundations of the Resource-Oriented Architecture (ROA). The current note is about two different types of URIs: URL and URN.

URI

Uniform Resource Identifier. A URI is a string of characters used to identify a resource. It is the name and address of a resource on the web.

As both URL and URN are URIs, all of the URL and URN examples showed below, are also valid as URI examples.

URL

Uniform Resource Locator. A URL is a URI that identifies a resource and also provides the means of locating the resource by describing the way to access it.

http://www.domain.com/books/software-in-30-days
ftp://ftp.is.co.za/rfc/rfc1808.txt
file:///home/username/RomeoAndJuliet.pdf
ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:John.Doe@example.com
news:comp.infosystems.www.servers.unix
telnet://192.0.2.16:80/
Valid URL exmples

URN

Uniform Resource Name. A URN is a URI. A URN only defines a name. It provides no details about how to get the resource over a network.

urn:oasis:names:specification:docbook:dtd:xml:4.1.2:
urn:isbn:0-486-27557-4
urn:mpeg:mpeg7:schema:2001
Valid URN examples

URNs are commonly used to define namespaces in XML Schema documents, such as:

<xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:example"...
The targetNamespace use a URN. It defines an identifier to the namespace, but it does not define a location.

Summing-up: both URL and URN are URIs as the both identify a resource. We can get a “thing” (a resource) via a URL, but we can’t get anything with a URN. If the URL describes both the location and name of a resource, the correct term to use is URI.

A URN functions like a person’s name, while a URL resembles that person’s street address.

Leave a Reply

Your email address will not be published. Required fields are marked *