-
Notifications
You must be signed in to change notification settings - Fork 10
URILiteralTemplate
Here we explain the syntax of URI and literal templates used in the target of the mapping axioms of an OBDA model.
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 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.
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.
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.
The types supported by -ontop- at the moment are:
- http://www.w3.org/2001/XMLSchema#string
- http://www.w3.org/2001/XMLSchema#int
- http://www.w3.org/2001/XMLSchema#integer
- http://www.w3.org/2001/XMLSchema#decimal
- http://www.w3.org/2001/XMLSchema#float
- http://www.w3.org/2001/XMLSchema#double
- http://www.w3.org/2001/XMLSchema#dateTime
- http://www.w3.org/2001/XMLSchema#boolean
- http://www.w3.org/2001/XMLSchema#date
- http://www.w3.org/2001/XMLSchema#time
- http://www.w3.org/2001/XMLSchema#gYear
- http://www.w3.org/2001/XMLSchema#positiveInteger
- http://www.w3.org/2001/XMLSchema#negativeInteger
- http://www.w3.org/2001/XMLSchema#nonPositiveInteger
- http://www.w3.org/2001/XMLSchema#nonNegativeInteger
- http://www.w3.org/2001/XMLSchema#long
- http://www.w3.org/2001/XMLSchema#unsignedInt
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.