Skip to content

Derive shapes from maps #125

@tpluscode

Description

@tpluscode

I would like to propose a new feature where minimal SHACL shapes are generated from the mappings. The purpose is to generate a starting point for defining more specific constraints over the output data. For example, given the mapping shown in the language reference

map AirportMapping from airport {
	subject template "http://airport.example.com/{0}" with id;
	
	graphs
		template "http://airport.example.com/graph/stop/{0}" with id;
		constant "http://www.w3.org/ns/r2rml#defaultGraph";
	
	types transit.Stop
	
	properties
		transit.route from stop with datatype xsd.integer;
		wgs84_pos.lat from latitude;
		wgs84_pos.long from longitude;
}

One would be able to produce a shape with minimal constraints.

<AirportMappingShape>
  a sh:NodeShape ;
  sh:targetClass transit:Stop ;
  sh:property 
    <AirportMappingShape/transit:route> ,
    <AirportMappingShape/wgs84_pos:lat> ,
    <AirportMappingShape/wgs84_pos:long> ;
.

<AirportMappingShape/transit:route>
  sh:path transit:route ;
  sh:datatype xsd:integer ;
  sh:nodeKind sh:Literal ;
.

<AirportMappingShape/wgs84_pos:lat>
  sh:path wgs84_pos:lat ;
  sh:nodeKind sh:Literal ;
.

<AirportMappingShape/wgs84_pos:long>
  sh:path wgs84_pos:long ;
  sh:nodeKind sh:Literal ;
.

It's important property shapes are named nodes, so that they would be extendable by adding properties in a separate document and merging them.
Give multiple mappings for same predicate might require sh:or or different node kind such as sh:NamedNodeOrLiteral


To implement this feature, I would propose to slightly adapt (and also simplify) the feature proposed in #115. I will create a draft PR to illustrate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions