Plugins You can find out about all the publicly available Grails plugins.

RDFa Plugin

  • Tags: rdf, rdfa
  • Latest: 0.1.1
  • Last Updated: 05 October 2009
  • Grails version: 1.1.1 > *
  • Authors: null
1 vote
compile "org.grails.plugins:rdfa:0.1.1"




grails install-plugin rdfa


RDFa Plug-in

The RDFa plug-in allows you to expose relevant parts of the structure of your application as RDFa annotations in your views. Both domain model (non-information resources) and controller actions (information resources) can be described.


To install the RDFa plug-in just run the following command

grails install-plugin rdfa


The RDFa plug-in provides a RDFaTagLib that can be used in any of your Grails views. To achieve this, the plug-in processes Groovy-to-RDF mappings in the domain model and in controllers.

Model mapping

An example of how to expose the domain model as RDFa can be seen below.

class Person {
	static rdf = [

String name static hasMany = [friends:Person] }

The mapped fields can now be referenced in views. Add a DOCTYPE declaration

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "">

and start using rdfa tags.

<rdfa:ul about="${person}">
	<g:each var="friend" in="${person.friends}">
		<rdfa:li rel="friends" resource="${friend}" property="name" />

Finally, the following XHTML+RDFa will be rendered:

<ul about="" typeof="ns1:Person" xmlns:ns1="">
	<li rel="ns1:knows" resource="" property="ns1:name">
		John Doe II
	<li rel="ns1:knows" resource="" property="ns1:name">
		John Doe III

Controller mapping

It is important to distinguish between the thing you're describing (the domain model object), and its description (the view rendered by a controller action). E.g., a Person in a domain model can have a name, whereas a document describing this person cannot, but can have other information such as creation date or terms of use. Hence, the controller needs an additional action for identifying domain objects, and the relation of controller actions to the domain model objects need to be specified.

class PersonController {
	static rdf = [
		resource: { },	// name of identifying action and identity field of domain model object

def show = { [person:Person.get(] }

def resource = { redirect(action:show, }

def image = { redirect(uri:"/images/default-avatar.png") } }

The mapped actions can now be referenced in views.

<rdfa:p about="${person}">
	<rdfa:img rel="image" alt="depiction of ${}" />

The following XHTML+RDFa will be rendered:

<p about="" typeof="ns1:Person" xmlns:ns1="">
	<img rel="ns1:depiction" src="" alt="depiction of John Doe I" >

Consuming Linked Data

You can also expose RDFa of other objects than just mapped domain model objects. Using the enclosed object triple mapping implementation, you can add resources from other datasets as well and reference them in views.

GraphService graphService
def berlin = graphService.get("", vocab.dbpedia.City)


  • beautiful XML namespace declarations (e.g., "foaf" instead of "ns1")
  • automatically guess, e.g., rel="friends" from <g:each in="${person.friends}">...</g:each>
  • Make better use of existing URLMapping (do not require ID closure in controller)