Support (R2)RML graph maps
Closed this issue · 2 comments
mchlrch commented
(this is a clone of #135):
R2RML can output triples to specific named graph defined using
rr:graphMap
property.Either as template
[] rr:subjectMap [ rr:graphMap [ rr:template "http://www.example.com/{@type}" ]; ].
or constant
[] rr:subjectMap [ rr:graphMap [ rr:constant ex:StopsGraph ]; ].I propose to add this as a language feature in the
map
block. Multiple should be allowedmap Subject from source { graph template "http://www.example.com/{0}" with Type graph constant "http://www.example.com/StopsGraph" # Also using prefixed names if possible graph constant ex.StopsGraph }
Sample XRM:
output r2rml
map Employee from EMPLOYEE {
subject template "http://example.org/employee/{0}" with EMPNO;
graphs
constant "http://example.org/AllEmployeeGraph" ;
template "http://example.org/EmployeeGraph/{0}" with EMPNO ;
types
schema.Person
}
Declaring graphs
is only supported for R2RML, RML and CARML output
. It's not supported for CSVW output.
Generally allowing to use RdfClass|RdfProperty|Datatype
as constant is useful and makes sense as well IMO.
# Also using prefixed names if possible
graphs
constant ex.StopsGraph ;
mchlrch commented
The following snippets show how graphmaps can be described in XRM and how it looks in generated R2RML
Sample XRM:
output r2rml
map ThingIntoGraphmapsMapping from ThingIntoGraphmapsSource {
subject template "http://example.org/thing/{0}" with id;
graphs
constant "http://example.org/graph/omnigraph"; // constant IRI as string
template "http://example.org/graph/thing-{0}" with id; // templated IRI with variable(s)
constant thing.Thing; // IRI from Class
constant thing.color; // IRI from Property
constant employee.myDatatype; // IRI from Datatype
}
logical-source ThingIntoGraphmapsSource {
type rdb
source "THINGS"
referenceables
id
}
Generated R2RML:
PREFIX rr: <http://www.w3.org/ns/r2rml#>
<#ThingIntoGraphmapsMapping> a rr:TriplesMap ;
rr:logicalTable [ rr:tableName "THINGS" ];
rr:subjectMap [
rr:template "http://example.org/thing/{id}" ;
rr:graphMap [
rr:constant <http://example.org/graph/omnigraph>;
]
;
rr:graphMap [
rr:template "http://example.org/graph/thing-{id}" ;
]
;
rr:graphMap [
rr:constant thing:Thing;
]
;
rr:graphMap [
rr:constant thing:color;
]
;
rr:graphMap [
rr:constant employee:myDatatype;
]
;
]
.
mchlrch commented
Updated documentation with zazuko/expressive-rdf-mapper@9c1e9f8