shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
24 stars 8 forks source link

Allow property paths in ShapeMaps #92

Open labra opened 5 years ago

labra commented 5 years ago

The current shape map specification allows node selectors like:

{ FOCUS rdf:type :Person}@<PersonShape>

to select all nodes that have type :Person to be checked as <PersonShape>.

It would be helpful to extend the grammar of node selectors to allow SPARQL property paths apart of single iris.

For example:

{ FOCUS rdfs:subClassOf*/rdf:type :Person}@<PersonShape>

The Shaclex implementation already supports this feature.

The grammar employed can be seen here

The relevant parts are in lines:

triplePattern    : '{' KW_FOCUS path (objectTerm | '_' ) '}' # focusSubject
                 | '{' (subjectTerm | '_') path KW_FOCUS '}' # focusObject
                 ;
status           : negation | questionMark ;
reason           : '/' string ;
jsonAttributes   : '$' ; // TODO

// SPARQL Grammar rule 82
path             : pathAlternative ;

pathAlternative  : pathSequence ( '|' pathSequence ) *
                 ;

pathSequence     : pathEltOrInverse ( '/' pathEltOrInverse ) *
                 ;

pathEltOrInverse : pathElt | inverse pathElt
                 ;

inverse          : '^'
                 ;

pathElt          : pathPrimary pathMod?
                 ;

// Todo: Add pathNegatedPrimarySet
pathPrimary      : nodeIri | rdfType | '(' path ')'
                 ;

pathMod          : '*'    # star
                 | '?'    # optional
                 | '+'    # plus
                 ;