Less code: eRDF templates for RDF-driven web sites

Keith Alexander experiments with using eRDF markup to populate HTML templates:

I was writing a php template, marking it up with eRDF, and I realised that what I was doing was describing variables with triples – which is essentially what I would be doing to write a SPARQL query to retrieve data for the template.

So the core of the idea is: using semantic markup in a template to generate queries, retrieve data and populate the template.

I have started to implement the idea, using eRDF for the semantic markup, SPARQL as the query language I generate to, and Smarty as the templating language. (I use the ARC RDF PHP classes for parsing the eRDF into triples, and for running the SPARQL queries).

Keith has blogged this in much more detail here, including code and template samples.

This is quite a clever idea. Let’s assume you have a web application driven by data from an RDF triple store. You generate HTML pages by querying the triple store and inserting the bits and pieces into an HTML template. Now if you add eRDF or RDFa annotations to the HTML template, in a way that reflects the original RDF data, then by definition the annotations completely specify what data you need to populate the page. And the template itself therefore must be sufficient to extract all the required triples from the store. No coding needed!

So, generalising the approach and glossing over many details: Just take a big ball of RDF data (dump or behind a SPARQL endpoint), and throw a bunch of HTML templates with embedded annotations at it, and you get a dynamic web site without writing any code. And the web site will have complete semantic annotations.

That’s an example of what becomes possible after you’ve payed the RDF tax.

Keith points out that this is similar to what Fresnel is designed to do, but I have to say that I find this template-based approach more appealing.

(Via simile-general)

This entry was posted in General, Semantic Web. Bookmark the permalink.

1 Response to Less code: eRDF templates for RDF-driven web sites

  1. Thanks for the write-up Richard. Another idea in my code (which complements the semantic templating, and also aims to diminish coding without diminishing developer control) is for a generic form processor: you write the form elements name attributes as associative array keys which reflect an RDF/XML like structure, and use special class names to tell the processor which functions the input value should be passed through.

    Post the form to the same url as the page it appears on, and the processor will parse the xhtml page to retrieve (only) the expected name => values, and pass them through the functions (which the developer can write) specified in the class attribute. If the form processes without errors, the resulting array can be saved to the RDF store.

Comments are closed.