Skip to content
Nikolaos Konstantinou edited this page Feb 12, 2016 · 14 revisions

The following are examples of the capabilities the R2RML Parser tool offers.

  1. Allow arbitrary SQL queries as logical views, using the rr:sqlQuery construct:

    map:dc-creator
    rr:logicalTable <#dc-creator-view>;
    rr:subjectMap [
    rr:template 'http://data.example.com/item/{"item_id"}';
    rr:class dcterms:BibliographicResource;
    ];
    rr:predicateObjectMap [
    rr:predicate dcterms:creator;
    rr:objectMap [ rr:column '"text_value"' ];
    ].
    <#dc-creator-view>
    rr:sqlQuery """
    SELECT i.item_id AS item_id, mv.text_value AS text_value
    FROM item AS i
    INNER JOIN metadatavalue AS mv
    ON i.item_id=mv.item_id
    INNER JOIN metadatafieldregistry AS mfr
    ON mfr.metadata_field_id=mv.metadata_field_id
    INNER JOIN metadataschemaregistry AS msr
    ON msr.metadata_schema_id=mfr.metadata_schema_id
    WHERE i.in_archive=TRUE AND
    mv.text_value IS NOT NULL AND
    msr.namespace='http://dublincore.org/documents/dcmi-terms/' AND
    mfr.element='creator'
    """.
    
  2. Allow functions in the SQL queries, for instance string manipulation functions (such as the SQL function replace), which can be nested:

    <#dc-language-view>
    rr:sqlQuery """
    SELECT h.handle AS handle,
    replace(replace(replace(replace(replace(replace(mv.text_value,'Greek','ell'),'Spanish','spa'),'German','deu'),'Italian','ita'),'English','eng'),'French','fra') AS text_value
    FROM handle AS h, item AS i, metadatavalue AS mv, metadataschemaregistry AS msr, metadatafieldregistry AS mfr WHERE
    i.in_archive=TRUE AND
    h.resource_id=i.item_id AND
    h.resource_type_id=2 AND
    msr.metadata_schema_id=mfr.metadata_schema_id AND
    mfr.metadata_field_id=mv.metadata_field_id AND
    mv.text_value is not null AND
    i.item_id=mv.item_id AND
    msr.namespace='http://dublincore.org/documents/dcmi-terms/' AND
    mfr.element='language' AND
    mfr.qualifier IS NULL
    """.
    
  3. Allow templates, using rr:template involving many table fields when generating URI's or Literals:

    map:persons
    rr:logicalTable [ rr:tableName '"eperson"'; ];
    rr:subjectMap [
    rr:template 'http://data.example.org/repository/person/{"eperson_id"}';
    rr:class foaf:Person;
    ];
    rr:predicateObjectMap [
    rr:predicate foaf:name;
    rr:objectMap [ rr:template '{"firstname"} {"lastname"}' ;
    rr:termType rr:Literal;
    ]
    ].
    
  4. Allow reference to other triple map subjects as objects to a triple map definition, using rr:RefObjectMap. Use of rr:joinCondition, rr:parent and rr:child is optional. In the following example, the objects in the map:TriplesMap1 mapping definition are the subjects in map:TriplesMap2. The rr:joinCondition states that the parent table field Sport.ID values are the ones that also exist in the child table field Student.Sport.

    map:TriplesMap1
    a rr:TriplesMap;
    rr:logicalTable [ rr:tableName  ""Student"" ];
    rr:subjectMap [ rr:template "http://example.com/resource/student_{"ID"}"; ];
    rr:predicateObjectMap
    [
    rr:predicate foaf:name ;
    rr:objectMap [ rr:column ""Name""; ];
    ];
    rr:predicateObjectMap
    [
    rr:predicate http://example.com/ontology/practises ;
    rr:objectMap [
    a rr:RefObjectMap ;
    rr:parentTriplesMap map:TriplesMap2;
    rr:joinCondition [
    rr:child ""Sport"" ;
    rr:parent ""ID"" ; ]
    ];
    ];
    .
    map:TriplesMap2
    a rr:TriplesMap;
    rr:logicalTable [ rr:tableName  ""Sport"" ];
    rr:subjectMap [ rr:template "http://example.com/resource/sport_{"ID"}"; ];
    rr:predicateObjectMap
    [
    rr:predicate rdfs:label ;
    rr:objectMap [ rr:column ""Name""; ];
    ];
    .
    
  5. See included example in the iswc folder where you will find:

Clone this wiki locally