Skip to content

Commit

Permalink
examples for new field subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
elsdvlee committed Dec 9, 2024
1 parent c2c3f5c commit c7149f3
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 1 deletion.
69 changes: 69 additions & 0 deletions test-cases/RMLLVTC0002-new/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

:jsonSource a rml:InputLogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.json" ;
] ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.people[*]" .

:jsonView a rml:LogicalView ;
rml:viewOn :jsonSource ;
rml:field [ a rml:ExpressionField;
rml:fieldName "name" ;
rml:reference "$.name" ;
] ;
rml:field [ a rml:IterableField;
rml:fieldName "item" ;
# rml:referenceFormulation rml:JSONPath
rml:iterator "$.items[*]" ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "type" ;
rml:reference "$.type" ;
] ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "weight" ;
rml:reference "$.weight" ;
] ;
] .

:triplesMapPerson a rml:TriplesMap ;
rml:logicalSource :jsonView ;
rml:subjectMap [
rml:template "http://example.org/person/{name}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasName ;
rml:objectMap [
rml:reference "name" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasItem ;
rml:objectMap [
rml:parentTriplesMap :triplesMapItem ;
] ;
] .

:triplesMapItem a rml:TriplesMap ;
rml:logicalSource :jsonView ;
rml:subjectMap [
rml:template "http://example.org/person/{name}/item/{item.type}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasName ;
rml:objectMap [
rml:reference "item.type" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasWeight ;
rml:objectMap [
rml:reference "item.weight" ;
rml:datatype xsd:integer ;
] ;
] .
11 changes: 11 additions & 0 deletions test-cases/RMLLVTC0002-new/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<http://example.org/person/alice> <http://example.org/hasName> "alice" .
<http://example.org/person/alice> <http://example.org/hasItem> <http://example.org/person/alice/item/sword> .
<http://example.org/person/alice> <http://example.org/hasItem> <http://example.org/person/alice/item/shield> .
<http://example.org/person/bob> <http://example.org/hasName> "bob" .
<http://example.org/person/bob> <http://example.org/hasItem> <http://example.org/person/bob/item/flower> .
<http://example.org/person/alice/item/sword> <http://example.org/hasName> "sword" .
<http://example.org/person/alice/item/sword> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/person/alice/item/shield> <http://example.org/hasName> "shield" .
<http://example.org/person/alice/item/shield> <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/person/bob/item/flower> <http://example.org/hasName> "flower" .
<http://example.org/person/bob/item/flower> <http://example.org/hasWeight> "15"^^<http://www.w3.org/2001/XMLSchema#integer> .
26 changes: 26 additions & 0 deletions test-cases/RMLLVTC0002-new/people.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"people": [
{
"name": "alice",
"items": [
{
"type": "sword",
"weight": 1500
},
{
"type": "shield",
"weight": 2500
}
]
},
{
"name": "bob",
"items": [
{
"type": "flower",
"weight": 15
}
]
}
]
}
53 changes: 53 additions & 0 deletions test-cases/RMLLVTC0006-new/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

:mixedCSVSource a rml:InputLogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.csv" ;
] ;
rml:referenceFormulation rml:CSV .

:mixedCSVView a rml:LogicalView ;
rml:viewOn :mixedCSVSource ;
rml:field [ a rml:ExpressionField;
rml:fieldName "name" ;
rml:reference "name" ;
] ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "items" ;
rml:reference "items" ;
rml:field [ a rml:IterableField ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$[*]"
rml:fieldName: "item" ;
rml:field [ e rml:ExpressionField ;
rml:fieldName "type" ;
rml:reference "$.type" ; ] ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "weight" ;
rml:reference "$.weight" ;
] ;
]
] .

:triplesMapItem a rml:TriplesMap ;
rml:logicalSource :mixedCSVView ;
rml:subjectMap [
rml:template "http://example.org/item_{#}_{item.#}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasType ;
rml:objectMap [
rml:reference "items.item.type" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasWeight ;
rml:objectMap [
rml:reference "items.item.weight" ;
rml:datatype xsd:integer ;
] ;
] .
6 changes: 6 additions & 0 deletions test-cases/RMLLVTC0006-new/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<http://example.org/item_0_0> <http://example.org/hasType> "sword" .
<http://example.org/item_0_0> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_0_1> <http://example.org/hasType> "shield" .
<http://example.org/item_0_1> <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_1_0> <http://example.org/hasType> "flower" .
<http://example.org/item_1_0> <http://example.org/hasWeight> "15"^^<http://www.w3.org/2001/XMLSchema#integer> .
3 changes: 3 additions & 0 deletions test-cases/RMLLVTC0006-new/people.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name,items
alice,"[{""type"":""sword"",""weight"":1500},{""type"":""shield"",""weight"":2500}]"
bob,"[{""type"":""flower"",""weight"":15}]"
2 changes: 1 addition & 1 deletion test-cases/RMLLVTC0006/mapping.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
rml:fieldName "item" ;
rml:reference "items" ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$[*]" ;
# rml:iterator "$[*]" ;
rml:field [
rml:fieldName "type" ;
rml:reference "$.type" ; ] ;
Expand Down
52 changes: 52 additions & 0 deletions test-cases/RMLLVTC0007-new/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

:mixedCSVSource a rml:InputLogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.csv" ;
] ;
rml:referenceFormulation rml:CSV .

:mixedCSVView a rml:LogicalView ;
rml:viewOn :mixedCSVSource ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "name" ;
rml:reference "name" ;
] ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "item" ;
rml:reference "item" ;
rml:field [ a rml:IterableField ;
rml:referenceFormulation rml:JSONPath ;
# rml:iterator "$[*]" ;
rml:field [ a rml:ExpressionField;
rml:fieldName "type" ;
rml:reference "$.type" ; ] ;
rml:field [ a rml:ExpressionField;
rml:fieldName "weight" ;
rml:reference "$.weight" ;
] ;
] ;
] .

:triplesMapItem a rml:TriplesMap ;
rml:logicalSource :mixedCSVView ;
rml:subjectMap [
rml:template "http://example.org/item_{#}_{item.#}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasType ;
rml:objectMap [
rml:reference "item.type" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasWeight ;
rml:objectMap [
rml:reference "item.weight" ;
rml:datatype xsd:integer ;
] ;
] .
6 changes: 6 additions & 0 deletions test-cases/RMLLVTC0007-new/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<http://example.org/item_0_0> <http://example.org/hasType> "sword" .
<http://example.org/item_0_0> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_1_0> <http://example.org/hasType> "shield" .
<http://example.org/item_1_0> <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_2_0> <http://example.org/hasType> "flower" .
<http://example.org/item_2_0> <http://example.org/hasWeight> "15"^^<http://www.w3.org/2001/XMLSchema#integer> .
4 changes: 4 additions & 0 deletions test-cases/RMLLVTC0007-new/people.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name,item
alice,"{""type"":""sword"",""weight"":1500}"
alice,"{""type"":""shield"",""weight"":2500}"
bob,"{""type"":""flower"",""weight"":15}"
53 changes: 53 additions & 0 deletions test-cases/RMLLVTC0008-new/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .

:mixedJSONSource a rml:InputLogicalSource ;
rml:source [
a rml:RelativePathSource , rml:Source ;
rml:root rml:MappingDirectory ;
rml:path "people.json" ;
] ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.people[*]" .

:mixedJSONView a rml:LogicalView ;
rml:viewOn :mixedJSONSource ;
rml:field [ a rml:ExpressionField
rml:fieldName "name" ;
rml:reference "$.name" ;
] ;
rml:field [ a rml:ExpressionField ;
rml:fieldName "items" ;
rml:iterator "$.items" ;
rml:field [ a rml:IterableField
rml:referenceFormulation rml:CSV ;
rml:field [ a rml:ExpressionField
rml:fieldName "type" ;
rml:reference "type" ;
] ;
rml:field [ a rml:expressionField ;
rml:fieldName "weight" ;
rml:reference "weight" ;
] ;
]
].

:triplesMapItem a rml:TriplesMap ;
rml:logicalSource :mixedJSONView ;
rml:subjectMap [
rml:template "http://example.org/item_{#}_{item.#}" ;
] ;
rml:predicateObjectMap [
rml:predicate :hasType ;
rml:objectMap [
rml:reference "item.type" ;
] ;
] ;
rml:predicateObjectMap [
rml:predicate :hasWeight ;
rml:objectMap [
rml:reference "item.weight" ;
rml:datatype xsd:integer ;
] ;
] .
6 changes: 6 additions & 0 deletions test-cases/RMLLVTC0008-new/output.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<http://example.org/item_0_0> <http://example.org/hasType> "sword" .
<http://example.org/item_0_0> <http://example.org/hasWeight> "1500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_0_1> <http://example.org/hasType> "shield" .
<http://example.org/item_0_1> <http://example.org/hasWeight> "2500"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/item_1_0> <http://example.org/hasType> "flower" .
<http://example.org/item_1_0> <http://example.org/hasWeight> "15"^^<http://www.w3.org/2001/XMLSchema#integer> .
12 changes: 12 additions & 0 deletions test-cases/RMLLVTC0008-new/people.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"people": [
{
"name": "alice",
"items": "type,weight\nsword,1500\nshield,2500"
},
{
"name": "bob",
"items": "type,weight\nflower,15"
}
]
}

0 comments on commit c7149f3

Please sign in to comment.