我正在尝试将 XML 源映射到 RDF,但似乎无法使多跳映射或多连接条件起作用。在浏览了文档、示例和测试用例之后,我不太确定这是否可能。
感谢您为解决此问题提供的任何帮助。
以下是一个简化的 XML 示例、到目前为止我创建的 RML 映射、使用RMLMapper生成的当前 RDF 输出以及我期望的 RDF 输出。
数据<Root>
<MainNode>
<name>main1</name>
</MainNode>
<OtherNode>
<name>other1</name>
<otherCondition>main1</otherCondition>
</OtherNode>
<OtherNode>
<name>other2</name>
<otherCondition>otherCond2</otherCondition>
</OtherNode>
<AnotherNode>
<name>another1</name>
<description>anotherDesc1</description>
<anotherCondition>other1</anotherCondition>
</AnotherNode>
<AnotherNode>
<name>another2</name>
<description>anotherDesc2</description>
<anotherCondition>anotherCond2</anotherCondition>
</AnotherNode>
</Root>
映射
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix testont: <http://www.example.com/ontology/> .
@prefix : <http://www.example.com/rules/> .
@base <http://www.example.com/instance/> .
:TriplesMapAnotherNode a rr:TriplesMap;
rml:logicalSource [
rml:source "multihop_data.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//AnotherNode"
].
:TriplesMapAnotherNode rr:subjectMap [
rr:template "{description}"
].
:TriplesMapOtherNode a rr:TriplesMap;
rml:logicalSource [
rml:source "multihop_data.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//OtherNode"
].
:TriplesMapOtherNode rr:subjectMap [
rr:template "{name}"
].
:TriplesMapMainNode a rr:TriplesMap;
rml:logicalSource [
rml:source "multihop_data.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//MainNode"
].
:TriplesMapMainNode rr:subjectMap [
rr:template "{name}"
].
:TriplesMapMainNode rr:predicateObjectMap [
rr:predicate rdf:type;
rr:object testont:MainClass
].
:TriplesMapOtherNode rr:predicateObjectMap [
rr:predicate testont:dummypredicate;
rr:objectMap [
a rr:RefObjectMap;
rr:parentTriplesMap :TriplesMapAnotherNode;
rr:joinCondition [
rr:child "name";
rr:parent "anotherCondition";
]
]
].
:TriplesMapMainNode rr:predicateObjectMap [
rr:predicate testont:hasDescription;
rr:objectMap [
a rr:RefObjectMap;
rr:parentTriplesMap :TriplesMapOtherNode;
rr:joinCondition [
rr:child "name";
rr:parent "otherCondition";
]
]
].
当前RDF
<http://www.example.com/instance/other1> <http://www.example.com/ontology/dummypredicate> <anotherDesc1>.
<http://www.example.com/instance/main1> <http://www.example.com/ontology/hasDescription> <other1>.
<http://www.example.com/instance/main1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/ontology/MainClass>.
预期的 RDF
<http://www.example.com/instance/main1> <http://www.example.com/ontology/hasDescription> <anotherDesc1>.
<http://www.example.com/instance/main1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/ontology/MainClass>.
简而言之,
- 如何根据 2 个加入条件加入 3 个节点?
- 如何跳过或避免创建三元组?
- 我可以根据 2 个以上的加入条件将其扩展为加入 3 个以上的节点吗?