Description

Most of the time, raw RDF data retrieved from the web must be adapted in order for it to be displayed in the application view. SemanticKO makes possible to pre-process RDF data to be displayed in different ways:

  • RDF properties for the bound RDF node can be retrieved and manipulated inside the data-bind attribute.
  • Properties can be defined in the view model and then used to define bindings in the data-bind attribute.
  • A RDF class object can be defined whose properties will be added to all the DOM nodes whose bound RDF node match the descriptoion of the RDF class.

The function sko.current can be used inside the data-bind attribute to retrieve the RDF node object bound to the current DOM node. Properties of this RDF node can be then retrieved using the function sko.current().tryProperty or sko.current().getProp. These function can also be used to define properties in the view model.

A more re-usable way of defining adapter functions is to define RDF class objects. These objects are collection of functions that will be added to a bound RDF node if the triples for that node matches the description of the RDF class. Descriptions for RDF classes can be build combining simple constructs: URIs, CURIEs, ObjectUnionOf, ObjectIntersectionOf and ObjectSomeValuesFrom. These building blocks can be combined to form complex class expressions testing for the presence of certain properties and or belonging to a list of RDF types.

In the example, four different ways of computing an adapted value for the foaf:name property of a RDF node is shown. Two of these ways involve the definition of two RDF class objects, one associated to all the RDF nodes whose type is foaf:Person and another one for all the RDF nodes with a value for the propert foaf:name: ObjectSomeValuesFrom([foaf:name]).

Output

View

Data (Turtle)

View Model