Skip to content
30 changes: 30 additions & 0 deletions shapes/lv.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,33 @@ rmlsh:InclusionAnnotationShape a sh:NodeShape;
sh:maxCount 1 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] .

rmlsh:parentCyclesShape a sh:NodeShape ;
sh:targetSubjectsOf rml:viewOn ;
sh:targetSubjectsOf rml:field ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "There must be no cycles via rml:viewOn or rml:Field." ;
sh:select """
PREFIX rml: <http://w3id.org/rml/>
SELECT ?this
WHERE {
?this (rml:viewOn|rml:field)+ ?this .
}
""" ;
] .

rmlsh:joinCyclesShape a sh:NodeShape ;
sh:targetSubjectsOf rml:viewOn ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "There must be no cycles via rml:viewOn and rml:leftJoin or rml:innerJoin." ;
sh:select """
PREFIX rml: <http://w3id.org/rml/>
SELECT ?this
WHERE {
?this a rml:LogicalView .
?this ((rml:leftJoin|rml:innerJoin)/rml:parentLogicalView)+ ?this .
}
""" ;
] .
2 changes: 1 addition & 1 deletion spec/section/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ When a non-existing or a non-referenceable key is referenced, RML processors sho
rml:field [
a rml:IterableField ;
rml:fieldName "item" ;
rml:reference "$.items[*]" ;
rml:iterator "$.items[*]" ;
rml:field [
a rml:ExpressionField ;
rml:fieldName "type" ;
Expand Down
39 changes: 39 additions & 0 deletions test-cases/RMLLVTC0008d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## RMLLVTC0008a

**Title**: Cycle: Fields

**Description**: Test a cycle in nested fields

**Error expected?** Yes

**Mapping**
```
@prefix rml: <http://w3id.org/rml/> .
@prefix : <http://example.org/> .

:jsonSource a rml:LogicalSource ;
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 :field1 .

:field1 a rml:IterableField ;
rml:fieldName "item" ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.items[*]" ;
rml:field :field2.

:field2 a rml:ExpressionField ;
rml:fieldName "type" ;
rml:reference "$.type" ;
rml:field :field1.

```

26 changes: 26 additions & 0 deletions test-cases/RMLLVTC0008d/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix : <http://example.org/> .

:jsonSource a rml:LogicalSource ;
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 :field1 .

:field1 a rml:IterableField ;
rml:fieldName "item" ;
rml:referenceFormulation rml:JSONPath ;
rml:iterator "$.items[*]" ;
rml:field :field2.

:field2 a rml:ExpressionField ;
rml:fieldName "type" ;
rml:reference "$.type" ;
rml:field :field1.
26 changes: 26 additions & 0 deletions test-cases/RMLLVTC0008d/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
}
]
}
]
}
Loading