today | current | recent | random ... categories | search ... who ... syndication

Me : Apache::XPointer


Last week, I read a paper from the 2004 International Semantic Web conference entitled A Semantic Web Resource Protocol: XPointer and HTTP. Long story short, it describes retrieving a non-linear subset of a document, via HTTP, by using the Range header to indicate your search criteria. XPointer formalizes the rules of the query scheme(s) : for plain-old XML, you might use XPath; for RDF, the RDF Data Query Language (RDQL).

Instead of pulling down a large document and processing it locally only to use a small amount of the data, you would make a normal GET or POST request, passing your limits in the Range header, and have the server send only the pieces you care about. Additionally, the proposal describes using the Accept header to indicate the desired content-type of the result set. For example, the source document may be written in a plain-text format, like N3, but the server would reformat it contingent on the client's request.

Like many ideas, this one didn't make the Earth move but it's both simple and clever and someone got around to writing it down. Over the weekend, I wrote a set of mod_perl handlers that adds support for XPointer via HTTP when serving static files with Apache. Currently the only schemes supported are XPath and RDQL, but the framework is extensible and allows for new schemes or a reimplementation of an exising scheme using another underlying library. For example, RDQL ranges are handled using the RDFStore Perl modules and you may prefer to use the Redland modules.

I also added code to accept standard CGI parameters, in the absence of corrresponding HTTP headers. This may seem silly on the face of it but it means that you can use these ideas in XSLT 1.0 stylesheets via the document function :

<xsl:variable name = "rdql">
 <xsl:text>SELECT ?foo WHERE ...</xsl:text>

<xsl:variable name = "ctype">

<xsl:variable name = "url">

<xsl:variable name = "result" select = "document($url) " />


In other words, you can retrieve a remote RDF document and pre-parse it using RDQL which is almost always going to be easier than achieving similar results with XPath.

The handlers will work with both the mod_perl 1.x and 2.x (1.99x) branches and are available via the CPAN. There is currently no support for caching which seems like an obvious next step. Otherwise they should Just Work ™.


refers to


Me : 1.2 ←  → Me : XPointerHttpRequest.js 1.0