0

我被困在 owl:Restriction 的映射上,并试图弄清楚如何使用RML Mapper来完成。

结果应该是:

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" .

从我得到的 JSONns:SomeResourcens:AnotherResource. 我的映射文件如下所示:

<#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
              ];

我尝试使用 predicateObjectMap 将限制放入主题图的 rr:class 中:

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 ] 
                            ];
                 ]
];

我承认这种方法很有创意,不幸的是它也不起作用,并且映射器停止并显示错误的绝对 IRI 错误消息。

我的另一个想法是使用字符串模板放入 predicateObjectMap :

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 ]
                      ];

这种方法看起来更有希望,但它将整行放在引号中:

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

我想知道是否可以自动进行映射,以防万一,这是如何正确完成的?

4

0 回答 0