RDF data are generated from the Annotated table (JSON) and extended Input (CSV) according to csv2rdf standard. We can export data in various RDF formats, for example Turtle or JSON-LD.

Example

<http://adequate.at/concept/city/aibl> a <http://adequate.at/concept/city> ;
 	dcterms:title "City", "LAU_NAME, "Town" ;
	dc:description "City of Austria" ;
	x:hasPopulationNat "39"^^<http://www.w3.org/2001/XMLSchema#integer> ;
    x:hasPopulationTotal "1386"^^<http://www.w3.org/2001/XMLSchema#integer> ;
    ad:liesIn <http://adequate.at/concept/district/deutschlandsberg> .
<http://adequate.at/concept/district/deutschlandsberg> a <http://adequate.at/concept/district>
    ...

Export process

RDF export consists of two parts:

  • fetch the triple patterns from Annotated table
  • create the triples from Input rows according to the patterns

Fetch the triple patterns

We read all columns from the Annotated table and try to recognize triple patterns they describe. When the column has the suppressOutput boolean flag set to true, we do not consider this column (it just holds the URIs and does not describe triples). If the propertyUrl is empty, no triple can be created (the predicate is missing). The same situation applies for empty aboutUrl (missing subject). When aboutUrl is not a column link (enclosed in curly braces), the column describes just one fixed triple statement, so we add this statement to the RDF Model directly (it is used for the statistical data cube definition). Then we finally can create the triple pattern. When the valueUrl is empty, we create a DataPropertyTriplePattern, where the object value in the column is literal). Otherwise we have two more options: When the separator is empty, we create a ObjectPropertyTriplePattern, where subject pattern is link to some column and object pattern can also be the link to the column or literal, so we save also the dataType. Otherwise the separator exists and we create a ObjectListPropertyTriplePattern, where the linked object column contains more resources separated by given separator.

Create the triples

Then we iterate over set of rows from the extended Input and for each row try to create the RDF triple from each triple pattern. First we create the subject. We expect only link to the column (in curly braces), So we find the value in given column and current row and when the value is not empty (and the column itself is not missing), we can create the IRI for subject.

IRI for predicate is already contained in the pattern, because we created it during creation of the pattern.

When the pattern is instance of DataPropertyTriplePattern, we assume that the object is literal, so when the value in given column and current row is not empty (and column is not missing), we can create literal for object (with dataType xsd:string). When there is instance of ObjectListPropertyTriplePattern, we must split the value according to given separator and for each resulting value create the IRI of object (so that more triples will be created). Finally it could be instance of ObjectPropertyTriplePattern, then the value can be IRI or literal. We can recognize it by checking the validity of IRI (valid IRI contains a colon). If it is literal and datatType is set and valid, we also set the dataType to the literal.

When we have the subject, predicate and objects created, we can add the new statements to the RDF Model. We use RDF4J library for creating the Model, which can be then easily exported by Rio to the specified RDF format.

Statistical data specifics

RDF export is processed the same way as for other than statistical data, it just includes processing of certain additional triples (without links to columns) and differentiates between creating of IRIs and Literals in object part of triples. Prefixes read from Annotated table "context" attribute are set to the RDF Model, so they are written to the header part of the resulting Turtle file.