The Semantics of 301 Moved Permanently

Section 10.3.2 of RFC2616 describes the HTTP status code 301 Moved Permanently. The first paragraph explains that the status code means that:

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible.

I was musing recently about the semantics of this response from an RDF perspective. Essentially we have a resource (/resource/a) which has been assigned a new permanent URI (e.g. /resource/b) and clients are licensed to treat all references to the old resource as references to the new.
It occured to me that this essentially means that the two URIs can be considered to be the same resource, i.e.:

</resource/a> owl:sameAs </resource/b> .

Using the HTTP Vocabulary in RDF (actually, the 1st March 2007 editors draft) we can write down an HTTP request and response like this:

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:http="http://www.w3.org/2006/http#">
<http:GetRequest rdf:ID="req0">
<http:requestURI rdf:resource="http://www.example.org/resource/a"/>
<http:response rdf:resource="#resp0"/>
</http:GetRequest>
<http:Response rdf:ID="resp0">
<http:responseCode rdf:resource="http://www.w3.org/2006/http#301"/>
<http:location rdf:resource="http://www.example.org/resource/b"/>
</http:Response>
</rdf:RDF>

I’m playing a bit loose with the http:requestURI property here as the specification states that it should have a literal value; although I’m not sure why as a URI is much more useful.
Now that we have an example GET and subsequent 301 response expressed in RDF, we can state the owl:sameAs semantics using rules. The following uses the Jena rules syntax:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;.
@prefix http: <http://www.w3.org/2006/http#&gt;.
@prefix owl: <http://www.w3.org/2002/07/owl#&gt;.
[MovedPermanently: (?request http:requestURI ?originalResource),
(?request http:response ?response),
(?response http:responseCode http:301),
(?response http:location ?newResource)
->
(?originalResource owl:sameAs ?newResource)]

The example document and rules are online, so you can test them using the xmlarmyknife rules engine, like this.
What do you think? Is this interpretation OK?

Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: