Wiki
Clone wikilmf / Module-Templating
About
The templating module allows to add templates to the system and to adapt the template to a URI resource. That means, that you are able to display resources with its properties and also more complex graph structure in a way that is familiar to usual web users. All parameters that are just used to control the templating process are removed or substituted by proper RDFa content.
http://wiki.lmf.googlecode.com/hg/images/templating2.png
Templating Syntax
This syntax of rdfa templating language (TL) is strongly leaned on Callimachus Templating Language. Like this, LMF's language is based on XHTML+RDFa. By now TL is under development and thus has not yet a fixed specification. Therefore we present the functionality that is implemented at the moment on a sample code. The code describes a template for a person.
<html> <head resource="?this"> <title rel="http://xmlns.com/foaf/0.1/name" content="?name"></title> </head> <body resource="?this"> <h1>Profile of <span id="fullname" rel="http://xmlns.com/foaf/0.1/name" content="?name"></span></h1> <h2>Basic Information</h2> <div rel="http://xmlns.com/foaf/0.1/depiction" max="2" resource="?img" style="float:left"> <img src="?img"/> </div> <div style="float:left"> <table> <tr><td>Name:</td><td><span rel="http://xmlns.com/foaf/0.1/surname" default="-" content="?sname"/></td></tr> <tr><td>Firstname:</td><td><span rel="http://xmlns.com/foaf/0.1/firstname" default="-" content="?fname" /></td></tr> <tr><td>Residence:</td> <td> <p reL="http://xmlns.com/foaf/0.1/based_near" datatype="uri" default="-" resource="?ort"> <a href="?place" title="?place"> <span rel="http://www.geonames.org/ontology#name" language="en|de" content="?p_name" default="?place" /> </a> </p> </td> </tr> </table> </div> <h2 rel="http://xmlns.com/foaf/0.1/surname" default="Friends" resource="?fname"><span content="?fname"></span>'s Friends</h2> <ul> <li rel="http://xmlns.com/foaf/0.1/knows" datatype="uri" resource="?friend" default="none :("> <a href="?friend"> <span rel="http://xmlns.com/foaf/0.1/name" content="?name" default="?friend"></span> </a> </li> </ul> </body> </html>
Variables
Variables starts with '?'. Variables are substituted with resources (URI or Literal) during the templating process. Variables can be bound within 'resource', 'about' or 'content' attribute. Variables can be used in 'title', 'src', 'link', or 'href'.
Basic Resource
The variable(s) in the dom tree, that have the shortest path to the root, are substituted by current resource. The name of the variable is arbitrary. The attributes that should be used are 'resource', 'about', or 'src'.
Relations
Relations are used to set the relation between the last bounding and a new variable. The relation must be defined via URI. 'rev', 'rel' or 'proptery' must be used as attributes for the relation. The variables can be bound within a 'resource' or a 'content' attribute. If relation has no results but the related dom element contains subelements, all subelements are removed.
Loops
Loops must not be defined in a special way. If a relation has more than one triple the regarding html element is repeated. A loop can be controlled with special attributes (max, language, default).
Special Attributes
TL allows special attributes to control relation-selection-handling.
Language Negotiation
Attribute: language ; Value Pattern: lang ( '|' lang )*, lang = string
The relation is filtered by languages. It is possible to set more then one language. The selection algorithm is FCFS. 'none' is a reserved literal that is defined as 'not annotated with any language'.
Maximum Relation Count
Attribute: max ; Value: positive integer
The number of relations is limited to max.
Default Value
Attribute: default; Value: string | variable
A default value can be defined to be e.g. displayed if relation has no triples.
Try it out
The source code contains some sample templates witch show how to use the templating sytax in order to create interfaces for several kind of resources (and properties). Use the configuration interface to upload new template files and test these files with LD resource.
E.g. upload template for dbpedia places and test it with resource http://dbpedia.org/resource/Berchtesgaden. The linked data caching module retrieves the needed information-graph automatically.
Updated