I am trying to map an XML source to RDF but cannot seem to get multi-hop mappings or multi-join conditions to work. After having gone through the documentation, examples, and test cases, I am not quite sure if this is even possible.
I appreciate any assistance in resolving this.
Following are a simplified sample XML, the RML mapping I created so far, the current RDF output generated using RMLMapper, as well as the RDF output I am expecting.
Data<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>
Mapping
@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";
]
]
].
Current 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>.
Expected 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>.
In short,
- how do I join 3 nodes based on 2 join conditions?
- how can I skip or avoid a triple from being created?
- can I extend this to join 3+ nodes based on 2+ join conditions?