Monday, 7 July 2014

URI vs. URL vs. URN

What's a URI?


Uniform Resource Identifiers (URIs) are used to identify 'names' or 'resources'. They come in 2 varieties: URNs and URLs. In fact, a URI can be both an URN and an URL!

What's a URL?


Uniform Resource Locators (URLs) provide a way to locate a resource using a specific scheme, most often but not limited to HTTP. Just think of a URL as an address to a resource, and the scheme as a specification of how to get there.

What's a URN?


Uniform Resource Names are identifiers for resources. They are location independent and make use of the urn: scheme.

What's the syntax of a URI?


scheme:scheme-specific-part?query#fragment

Examples from the RFC:
ftp://ftp.is.co.za/rfc/rfc1808.txt
http://www.ietf.org/rfc/rfc2396.txt
ldap://[2001:db8::7]/c=GB?objectClass?one
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

What's the syntax of a URL?


scheme://username:password@subdomain.domain.tld:port/path/file-name.suffix?query-string#hash

Examples:
http://www.google.com
http://foo:bar@w1.superman.com/very/long/path.html?p1=v1&p2=v2#more-details
https://secured.com:443
ftp://ftp.bogus.com/~some/path/to/a/file.txt

What's the syntax of a URN?


urn:namespame-identifier:namespace-specific-string

Examples from Wikipedia:
urn:isbn:0451450523
urn:ietf:rfc:2648
urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66

What's an XML Namespace?

<ui:composition
        contentType="text/html"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:s="http://jboss.org/schema/seam/taglib"
        xmlns:git="http://www.gouwit.nl/jsf/corepresentation"
        xmlns:gbl="http://www.gouwit.nl/jsf/bl
        xmlns:g="http://java.sun.com/jsf/composite/components
        xmlns:p="http://primefaces.org/ui
        template="/layout/template_globals.xhtml"
>

An XML Namespace name is a uniform resource identifier (URI). However, the namespace specification does not require nor suggest that the namespace URI be used to retrieve information; it is simply treated by an XML parser as a string.

In general users should assume that the namespace URI is simply a name, not the address of a document on the Web.

Updated: 2014-09-18, added XML Namespace note.

References

Freeformatter.com
http://www.freeformatter.com/url-parser-query-string-splitter.html
Stackoverflow - What is the difference between a uri and a url
http://stackoverflow.com/questions/176264/whats-the-difference-between-a-uri-and-a-url
IETF - RFC3986
http://www.ietf.org/rfc/rfc3986.txt
Wikipedia - XML namespace
http://en.wikipedia.org/wiki/XML_namespace

1 comment: