ArticlesForumDownload AboutContact

boakes.org

nice of you to drop by. tea?

Tags: RDFX, Semantic Computing

RDF Content Negotiation (Apache and Java)

September 23rd, 2004, by Rich.

I notice that several folk are arriving at the rdf namespace oddness page which describes the slightly opaque problem of understanding RDF Schema URI’s and how to go about loading them.

I’ve long since found a solution, following a discussion on #rdfig a long time back. That solution is content negotiation, so for the record, here’s how I’ve done it.

Negotiation of application/rdf+xml content using Java

This is how to load an RDF file using content negotiation and then pass the content onto Jena (original).

[java]String u = “http://rdfx.org/schema/2004/10/19-java”;
URL url = new URL(u);

URLConnection urlc = url.openConnection();
urlc.setRequestProperty(”Accept”, “application/rdf+xml”);
urlc.connect();

InputStream in = urlc.getInputStream();
model.read(inStream, u);
inStream.close();[/java]

Apache Server Configuration for RDF Content Negotiation

The server for rdfx.org is set up so that if a browser requests http://rdfx.org/schema/2004/10/19-java an html based page is generated, but using the above code and the same URI, a raw RDF file can be aquired.

The configuration for the RDFX.org server is as follows:

[xml]
ServerAdmin rdfx@example.org
DocumentRoot /home/www/rdfx.org/htdocs
DirectoryIndex index.php index.html index.rdf

AllowOverride All
Options MultiViews
AddType application/rdf+xml rdf

[/xml]

I hope this helps someone out there, I got some nasty splinters from all the head-scratching.

Leave a Reply