Skip to content
ebotoeva edited this page Mar 6, 2015 · 1 revision

Here we explain the syntax of URI and literal templates used in the target of the mapping axioms of an OBDA model.

Table of Contents

URI Template

URI templates are used in the target of mapping axioms for identification of generated objects. A URI Template is an arbitrary string with placeholders, e.g., <http://www.example.org/library#BID_{id}>. More than one placeholder can appear in a URI template, which allows to construct complex URI paths. For example:

mappingId     Spare parts
source        SELECT product, part, vendor FROM product
target        <http://example.org/{vendor}/{product}/{part}> a :Part .

Note that you can repeat place holders in a URI template as you please.

Prefixes in URI Templates

Prefixes can be used when writing a URI template. Every prefix will be replaced by its definition when ontop parses the mappings.

Example. Assume that the following prefixes are defined:

PREFIX   :	http://www.example.org/ontology1#
PREFIX   p:	http://www.example.org/ontology2#

Then this mapping axiom:

mappingId     Example
source        SELECT col1, col2 FROM table
target        <http://www.example.org/ontology1#{col1}> :property <http://www.example.org/ontology2#{col2}>

is equivalent to this mapping axiom:

mappingId     Example
source        SELECT col1, col2 FROM table
target        :{col1} :title p:{col2}
Beware not to use angle brackets in combination with prefixes. That is, the following is wrong syntax:
mappingId     Example
source        SELECT col1, col2 FROM table
target        <:{col1}> :title <p:{col2}>

Note that the prefixes must be defined in advance. The default prefix : is always available and it is the URI of the ontology.

Literal Template

The simplest literal template is merely a placeholder, e.g., {name}. Since in an RDF graph literals can be typed and have language tags, a literal template can also be typed and tagged.

Literal Typing

It is possible to create typed literals by specifying the type in the mapping. For example:

mappingId     Book titles
source        SELECT id, title, edition, comment FROM books
target        :BID_{id} :title {title}^^xsd:string; :edition {edition}^^xsd:int; :description {comment} .

The type used in the mapping has to agree with the type in the ontology (if specified). If the type is not specified (for example, for the description property in the previous mapping), the system will look at the SQL type of the SQL column used in the mapping and will use the Natural Mapping of SQL values as defined by R2RML standard.

Supported Types

The types supported by -ontop- at the moment are:

Included in releases after 1.12.0: Included in releases after 1.13.1:

Language tags

Language for a literal can be specified directly using symbol '@', for example:

mappingId     Book titles in Italian
source        SELECT id, title FROM books where lang='ITALIAN'
target        :BID_{id} :title {title}@it .

Or it can be obtained from the database through a column reference. For example:

mappingId     Book titles in Italian
source        SELECT id, title, lang FROM books
target        :BID_{id} :title {title}@{lang} .

Note that in the second case, the value of the column containing the language tag must be a valid RDF language tag normalized to lower-case.

Clone this wiki locally