sparna-git / Sparnatural

Sparnatural : visual knowledge graph explorer with SPARQL, in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
225 stars 41 forks source link

SHACL property paths #652

Closed ch-sander closed 1 month ago

ch-sander commented 1 month ago

How is the SHACL config to be defined for some wildcard property that follows any path to some range object? That's easy in SPARQL but I didn't see any way in SHACL.

SELECT ?subject
WHERE {
  ?subject (<>)* ?object .
  ?object a ex:TargetClass .
}

Can sh:zeroOrMorePath be a not defined property? If impossible, it might be a considerable constraint, I find. Maybe the Sparnatural config could also allow for a SPARQL substitute in addition to native SHACL sh:path processor?

tfrancart commented 1 month ago

That query isn't doing what you think it does. <> is not a wildcard. This is a relative URI, relative to the base URI. A wildcard pattern would be ?p*. However using variables in property paths is not allowed in SPARQL. This is a "considerable limitation" of SPARQL, and has nothing to do with SHACL.

ch-sander commented 1 month ago

Gosh, I guess I'm still learning... Anyways, I could just create a property path considering all known n properties of the graph to achieve this in SHACL or SPARQL.

tfrancart commented 1 month ago

You could use something like (!rdf:type)* (anything except rdf:type)