1

URL is an URI which identifies a resource by location.

Resource representation is a view of resource's state. This view is encoded in one or more transferable formats, such as XHTML, Atom, XML, MP3 ...

URIs associate resource representations with their resources

a) So I assume URI identifies a resource and not resource representation?

b) I've read that relationship between an URI and resource representation is one to many. Assuming we're talking about URL, how can a single URL address more than one resource representation?

thank you

3

With content negotiation. http://en.wikipedia.org/wiki/Content_negotiation

When you dereference your URI using HTTP, you pass an "Accepts" header with the different mime types you're willing to take. For example, you might be able to read JSON, XML or plain text: "application/json application/xml text/plain". Whatever resource you're reading (or writing) might come back as a representation in any of those formats.

In practice, most applications deal with one representation. Usually it's just HTML, JSON, or XML. Sometimes a framework can render data resource with either JSON or XML, based on the Accepts header. But since we usually write code for one representation, or else the parsing is hidden by our framework, it kind of feels like the resource just has one representation. But that's just a perception.

  • Sorry for being so dense. A - By "dereference your URI" you mean something like typing an URL in your browser? B – By "usually write code for one representation" you mean, for example, apps which display representations usually only know to read one format ( like XML ) and not several of them? C – btw, I assume URI indeed identifies a resource and not resource representation? – bckpwrld Jun 2 '14 at 20:30
  • 1
    A) "deference" just means looking it up & send a request to it. Which could be a POST. Maybe I'll edit to say "make a request to...". B) Most of the frameworks I've worked with can handle either JSON or XML (or YAML), but in practice we just pick one and code & test that. C) Correct -- URI is kind of like a primary key for the web. A "resource" is a very broad term that means any bundle of data that we can package up and send. Sometimes a URI identifies something where the URI isn't an actual address to a server somewhere. We just use the URI format for convenience. – Rob Jun 2 '14 at 22:00
  • 1
    C++) And the representation is just how we wrap it up for transmission. But the underlying idea stays the same, whether it's rendered in JSON, XML, HTML, or YAML. – Rob Jun 2 '14 at 22:02
  • 1
    I've already accepted it as an answer. But in case you're still reading this: "most applications deal with one representation" I assume browsers are an exception to this rule, since they can handle HTML, XML, pdf, MP3 and various other formats? – bckpwrld Jun 2 '14 at 22:21
  • 1
    Very good observation. I mostly work with RESTish services, so I'm mainly streaming JSON in and out. But, you're right, most of the resources a browser handles comes in all kinds of flavors. Good point. – Rob Jun 2 '14 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.