RML Mapping - How to map a restriction?

213 views Asked by At

I am stuck on the mapping of an owl:Restriction and trying to figure out how that could be done using the RML Mapper.

The result should be:

prefix ns: <http://example.org/> .
ns:SomeResource rdf:type owl:NamedIndividual ,
   [ rdf:type owl:Restriction ;
     owl:onProperty <http://example.org/myProperty> ;
     owl:allValuesFrom ns:AnotherResource 
   ] ;
   rdfs:label "label" .

From the JSON I get ns:SomeResource and ns:AnotherResource. My mapping file looks like this:

<#RestrictionMap> rdf:type rr:TriplesMap;
rml:logicalSource [
                    rml:source "myJSON.json";
                    rml:referenceFormulation ql:JSONPath;
                    rml:iterator "$.myIterator[*]"
                  ];

rr:subjectMap [
                rr:template "http://example.org/{Id}" ;
                rr:class owl:NamedIndividual
              ];

I tried to put the restriction into the rr:class of the subject map using a predicateObjectMap:

rr:subjectMap [
                rr:template "http://example.org/{Id}" ;
                rr:class [ rr:predicateObjectMap [                                                                  
                                       rr:predicate rdf:type ;                                                           
                                       rr:objectMap [                                                                                
                                                rr:template "http://www.w3.org/2002/07/owl#Restriction" ;                                                                           
                                                rr:termType rr:IRI ] ;                                                                                                                        ] ;
                            rr:predicateObjectMap [
                                       rr:predicate owl:onProperty ;                                                                
                                       rr:objectMap [
                                                    rr:template "http://example.org/myProperty" ;
                                                    rr:termType rr:IRI ] 
                            ];
                 ]
];

I admit that this approach is creative, unfortunately it also does not work and the mapper stops with an error message of a wrong absolute IRI.

My other idea was to put into a predicateObjectMap using a string template:

rr:predicateObjectMap [
                      rr:predicate rdf:type ;
                      rr:objectMap [
                                   rr:template "[ rdf:type owl:Restriction ; owl:onProperty <http://example.org/myProperty> ; owl:allValuesFrom {AnotherResource} ]";
                                   rr:termType rr:Literal ]
                      ];

This approach looks a bit more promising, but it puts the whole line in quotes:

<http://example.org/SomeResource>
    rdf:type "[ rdf:type owl:Restriction ; owl:onProperty <http://example.org/myProperty> ; owl:allValuesFrom AnotherResource ]" ;

I wonder whether it is possible to do the mappings automatically and, in case, how this is done correctly?

0

There are 0 answers