<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="pto" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#">
<info>
    
    
    
    
    
    
    
<title>WITW Part III: RESTful Landmarks</title><biblioid class="uri">http://norman.walsh.name/2005/02/21/witw-landmarks</biblioid>
<volumenum>8</volumenum>
<issuenum>28</issuenum>
<pubdate>2005-02-21T15:06:27-05:00</pubdate>
<date>$Date: 2005-09-11 10:27:02 -0400 (Sun, 11 Sep 2005) $</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2005</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>Keeping track of landmarks.</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#WebServices"/>
</info>

<epigraph>
<attribution>
      <personname>
	<firstname>William</firstname>
<surname>Shakespeare</surname>
      </personname>
    </attribution>
<literallayout>And gentlemen in England now a-bed
Shall think themselves accursed they were not here,
And hold their manhoods cheap whiles any speaks
That fought with us upon Saint Crispin's day.</literallayout>
</epigraph>

<para xml:id="p1">Instead of working on WSDL, which would arguably
have been more informative, I've done something fun instead.
Registered users can now supply a collection of landmarks. These
landmarks will be used (aggregated with other users') in displaying
the set of landmarks that are “nearby” for each user.</para>

<para xml:id="p2">What's more, I think I have a properly
<link xlink:href="http://en.wikipedia.org/wiki/REST">RESTful</link>
interface to the landmarks data.</para>

<para xml:id="p3">The landmarks URI is
<link xlink:href="http://norman.walsh.name/2005/02/witw/ami/landmarks">http://norman.walsh.name/2005/02/witw/ami/landmarks</link>. Note that this URI
is in the authentication realm for registered users.</para>

<para xml:id="p4">Performing an HTTP GET on the landmarks URI will return
the landmark data for the authenticated user. The resulting data will
be valid according to the
<link xlink:href="examples/landmarks.rnc">landmarks schema</link>.</para>

<para xml:id="p5">Performing an HTTP POST on the landmarks URI will update
the set of landmarks. The posted document must be valid according to
the landmarks schema. The landmarks provided will be added to the existing
collection. If one of the posted landmarks has the same name as an existing
landmark, the existing landmark will be replaced by the posted one.</para>

<para xml:id="p6">Performing an HTTP PUT on the landmarks URI will
replace the set of landmarks. The replacement document must be valid
according to the landmarks schema.</para>

<section xml:id="clever">
<title>Clever Usability Tricks</title>

<para xml:id="p7">I don't know if this is a clever trick or an awful hack,
but if you GET the landmarks URI with a browser that accepts the
<literal>application/xhtml+xml</literal> media type and understands
client-side XSL stylesheets, the transformed result of the landmarks
data will include a form. If you complete that form and submit it, you
will effectively POST a single landmark to your collection.</para>

<para xml:id="p8">That means that you don't need to figure out how to
POST or PUT data to the landmarks URI in order to add some landmarks.</para>
</section>
</essay>

