The basic idea behind SemanticKO is binding RDF nodes to DOM nodes. RDF nodes are related to each other using property URIs. DOM nodes are related to each other through a parent-child relationship. The HTTP rel
attribute can be used in SemanticKO to bind a RDF node to a DOM node that is a child of a DOM node already bound to the RDF graph. The object node at the other end of the property will be the RDF node bound to the related DOM node.
In this example the property tests:inventorOf
relates the RDF node with information about Joh McCarthy to the RDF node with information about the Lisp programming language. This property, used in the rel
HTML attribute of a td
node is used to bound that node to the RDF node for Lisp. This is possible because this td
node is a childe of a tr
DOM node that is already bound to the McCarthy RDF node using the about
HTML attribute.
In this example the the view model is also an empty object, since the whole RDF graph is used as the view model. The sko.registerPrefix
function is used to register the tests
prefix. After the registration, we can write compact URIs (CURIEs) like tests:inventorOf
instead of the full URI. The library registers by default some well known prefixes, like foaf
, rdf
or rdfs
. This is why they are directly used in the view without producing errors.