Skip to content

Error or NULL value when a reference is not found in the source data #81

@elsdvlee

Description

@elsdvlee

Suppose source data:

{
  "people": [
    {
      "name": "alice",
      "items": [
        {
          "type": "sword",
          "measures": {
            "weight": 1500,
            "length": 30
          }
        },
        {
          "type": "shield",
          "measures": {
            "weight": 2500
          }
        }
      ]
    },
    {
      "name": "bob",
      "items": [
        {
          "type": "flower",
          "measures" : {
            "weight": 15,
            "length" : 15
          }
        }
      ]
    }
  ]
}

and mapping:

@prefix rml: <http://w3id.org/rml/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@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 [
    a rml:ExpressionField ;
    rml:fieldName "name" ;
    rml:reference "$.name" ;
  ] ;
  rml:field [
    a rml:IterableField ;
    rml:fieldName "item" ;
    rml:iterator "$.items[*]" ;
    rml:field [
      rml:fieldName "type" ;
      rml:reference "$.type" ;
    ] ;
    rml:field [
      a rml:IterableField ;
      rml:fieldName "measures";
      rml:iterator "$.measures";
      rml:field [
        a rml:ExpressionField ;
        rml:fieldName "length" ;
        rml:reference "$.length" ;
      ]
    ] ;
  ] .

:triplesMapItem a rml:TriplesMap ;
  rml:logicalSource :jsonView ;
  rml:subjectMap [
    rml:template "http://example.org/person/{name}/item/{item.type}" ;
  ] ;
  rml:predicateObjectMap [
    rml:predicate :haslength ;
    rml:objectMap [
      rml:reference "item.measures.length" ;
      rml:datatype xsd:integer ;
    ] ;
  ] .

Should the RML Engine throws an error because the length of the shield of alice is missing?
Or should it just not produce that triple?
In RML-Core, the RML Engine should throw an error when the reference is invalid, see RMLTC0023a-JSON.
@pmaria, @chrdebru, @bjdmeest, @dachafra What is your opinion? Is a jsonpath expression returning no results for some iterations the same as a missing column, also if it returns results for other iterations?

In the meanwhile, I will already correct RML LV 2c, where this field is not used in any triple maps and can/must be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingawaiting completion of another issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions