Warning:
This wiki has been archived and is now read-only.

Shape Selectors

From RDF Data Shapes Working Group
Jump to: navigation, search

The disagreement that motivated this solution was that some people (let's call them the class-centric camp) would like to treat some classes as shapes, and use the instance-of relationship (rdf:type) to select which shapes need to be evaluated. Another school of thought (let's call them the shape-centric camp) would prefer to have classes and shapes completely separated, and use dedicated new properties (such as ldom:nodeShape) to link a resource with the shapes that it needs to match. There is an intermediate proposal that would allow a mixture of both, using rdf:type to jump to a class and then ldom:classShape to the shape of the class.

This page is an attempt to formalize and generalize the issue of classes-vs-shapes so that the WG can reach consensus. If there are two different approaches to a problem, many W3C groups create a solution that allows both approaches to co-exist. Often, W3C groups also come up with a mechanism to switch between different dialects or profiles, so that users can switch between two approaches, and stakeholders can continue with their preferred way of working in "their" dialect.

In this proposal, the LDOM system vocabulary can be used to represent which properties shall be used to drive the LDOM engine.

The main concept in this is the class ldom:ShapeSelector:

   ldom:ShapeSelector
       a rdfs:Class ;
       rdfs:subClassOf rdfs:Resource ;
       rdfs:label "Shape selector" ;
       rdfs:comment "Specifies which properties (or more generally: paths) shall be used by the LDOM engine to select shapes." ;
       ldom:property [
               ldom:predicate ldom:shapeExtensionPath ;
               ldom:valueType ldom:Path ;
               rdfs:label "shape extension path" ;
               rdfs:comment "Zero or more paths (properties) that link a shape with more general (parent) shapes." ;
       ] ;
       ldom:property [
               ldom:predicate ldom:shapeSelectionPath ;
               ldom:valueType ldom:Path ;
               ldom:minCount 1 ;
               rdfs:label "shape selection path" ;
               rdfs:comment "One or more paths (properties) that link individual resources with the shape(s) that they are expected to match against." ;
       ] .

In a nutshell, a ShapeSelector defines:

  • zero or more properties (or paths) that link a shape with a more general shape, to "walk up" the shape hierarchy and allow some kind of inheritance or extension mechanism between shapes
  • one or more properties (or paths) that link a resource/instance/individual with the shape(s) that it is supposed to match against.

When an LDOM constraint checking engine is started, it would receive a ShapeSelector as its input, and adjust its behavior accordingly. The vocabulary could also suggest mechanisms to link a graph with its default ShapeSelector.

The LDOM system vocabulary pre-defines one such ldom:ShapeSelector, which is also used by the system vocabulary itself:

   ldom:ClassBasedShapeSelector
       a ldom:ShapeSelector ;
       rdfs:label "Class-based shape selector" ;
       rdfs:comment "Selects shapes based on the traditional RDF datamodel. rdf:type is used to link resources with the shapes they are supposed to match. rdfs:subClassOf is used to link a shape with its more general parent shape. This selector is used by the LDOM system vocabulary itself, e.g. to test LDOM models." ;
       ldom:shapeSelectionPath rdf:type ;
       ldom:shapeExtensionPath rdfs:subClassOf .

A typical structure using this selector looks like

   ex:Shape
       a rdfs:Class ;
       ldom:property [
           ldom:predicate ex:property ;
           ldom:minCount 1 ;
       ] .
   
   ex:Instance
       rdf:type ex:Shape ;
       ex:property "value" .

Here is another possible selector:

   oslc:OSLCShapeSelector
       a ldom:ShapeSelector ;
       rdfs:label "OSLC shape selector" ;
       ldom:shapeSelectionPath oslc:instanceShape ;
       ldom:shapeSelectionPath [ 
           a ldom:SequencePath ; 
           ldom:path1 rdf:type ;
           ldom:path2 oslc:classShape ;
       ] .

The selector above supports two ways of finding the shape for a resource:

  • via a direct link (oslc:instanceShape)
  • via a path expression (rdf:type/oslc:classShape)

An example data model for this selector would be:

   ex:Shape
       a oslc:ResourceShape ;
       ldom:property [
           ldom:predicate ex:property ;
           ldom:minCount 1 ;
       ] .
   
   ex:Instance
       oslc:instanceShape ex:Shape ;
       ex:property "value" .

but the following would also work:

   ex:MyClass
       a owl:Class ;
       oslc:classShape [
           ldom:property [
               ldom:predicate ex:property ;
               ldom:minCount 1 ;
           ] 
       ] .
   
   ex:Instance
       a ex:MyClass ;
       ex:property "value" .