ObdaFileFormat - ontop/ontop GitHub Wiki

valid for Ontop Version 1

OBDA File Structure

Starting from version 1.7 (build 1599), -ontop- introduces a new format of OBDA text file which users can edit by hand.

An OBDA file in full skeleton:

[PrefixDeclaration]
...

[SourceDeclaration]
...

[MappingDeclaration] @collection [[
...
]]

The detail of the specification is as follows:

Prefix Declaration

This section is the place where users put all the prefix definitions used inside the system.

Keyword header: [PrefixDeclaration]

Each prefix is declared by a pair of its identifier (or name) and its URI definition. For example, to have the default prefix, XSD, OWL and RDF prefixes, the prefix declaration will contain:

[PrefixDeclaration]
:		http://www.example.org/ontology#
xsd:		http://www.w3.org/2001/XMLSchema#
owl:		http://www.w3.org/2002/07/owl#
rdf:		http://www.w3.org/1999/02/22-rdf-syntax-ns#

Note: there should be no newlines between each entry or the system will fail to read the declarations.

Source and Mapping Declaration

This last section defines the data connection parameters and the mapping assertions. These two declaration sections are considered as one block where each mapping corresponds to the datasource defined at the beginning. Thus, to define different mappings that map to another datasource, users can add another block of source and mapping declaration subsequently and the system will treat them separately.

Data source declaration keyword header: [SourceDeclaration]

This part describes the connection parameters in order to access the database. There are five parameters users have to provide (no newlines should be introduced between each parameter).

For example:

[SourceDeclaration]
sourceUri	book-connection
connectionUrl	jdbc:postgresql://example.org/db/book
username	jsmith
password	12345
driverClass	org.postgresql.Driver

Mapping declaration keyword header: [MappingDeclaration]

Each mapping is declared by writing its identifier, target and source and separated by a newline for the next mapping.

For example:

[MappingDeclaration] @collection [[
mappingId     Book collection
target        :BID_{id} a :Book .
source        SELECT id FROM books

mappingId     Student list
target        :{fname}_{lname} a :Student .
source        SELECT 
                 fname, lname 
              FROM 
                 students
...
]]

{|style="border-style: solid;" |Notice that the separator between parameter names and values is TAB instead of SPACE. For example (with whitespace characters visible, i.e., TAB symbol (») and SPACE symbol (•)):

mappingId»  collection
target»  »  :BID_{id} a :Book .
source»  »  SELECT id FROM books

mappingId»  Student list
target»  »  :{fname}_{lname} a :Student .
source»  »  SELECT 
»  »  »  »  •••fname, lname 
»  »  »  »  FROM 
»  »  »  »  •••students

Note: There should not be any extra lines at the end of the document before ]]. Otherwise it causes an exception. |}

It is possible to compact more mappings:

mappingId     Student list
target        :{fname}_{lname} a :Student .
source        SELECT fname, lname FROM students

mappingId  Student id
target      :{fname}_{lname} :hasId {id} .
source     SELECT fname, lname, id FROM students

Writing them as:

mappingId     Student information
target        :{fname}_{lname} a :Student ; :hasId {id} .
source        SELECT fname, lname, id FROM students

Note: Remember to add a space before and after semicolumn in the target.

Useful Information

⚠️ **GitHub.com Fallback** ⚠️