W3C home > Mailing lists > Public > public-data-shapes-wg@w3.org > March 2016

SHACL recursion based on SPARQL (idea)

From: Dimitris Kontokostas <kontokostas@informatik.uni-leipzig.de>
Date: Thu, 3 Mar 2016 08:54:26 +0100
Message-ID: <CA+u4+a29G4GdGLYBpSUd-w1Oov_+8NNy_2+5JjzL-a_o2i+Z2A@mail.gmail.com>
To: public-data-shapes-wg <public-data-shapes-wg@w3.org>
I maybe surprising to the group that I make such a proposal :) but had a
(crazy) idea about enabling *some* recursion on shacl that is consistent
with the rest of the spec and is based in SPARQL.

The basic idea is to use implicit scopes and property paths to achieve that
goal.
(Note that I have not yet implemented this, this is just a draft idea and
wanted to see if you would like to explore more on this)

Example:
ShpA (scopeClass ex:Person, property(p1, valueShape: ShpB))
ShpB ( property (p2, isIRI, (valueShape: ShpC))
ShpC ( property (p3, isIRI, (valueShape: ShpA))

In this approach, every shape may have an explicit scope (such as
scopeClass, scopeNode, etc) as well as implicit scopes that derive from
sh:valuShape.
to identify the implicit scope of a shape we traverse all the current shape
references to that shape from other shapes and give them implicit scopes
only if the other shapes have an explicit scope.
An example with make it easier to understand

(note that this is without recursion and is  how RDFUnit has currently
implemented sh:valueShape)
ShpA has an explicit scope with scopeClass ex:Person (we do not take ShpC
into account here)
ShpB has no explicit scope and 1 implicit scope: [a ex:Person] / p1
ShpC has no explicit scope and 1 implicit scope: [a ex:Person] / p1 / p2

note that ShpC gets an implicit scope from ShpA only as ShpB has no
explicit scope, if it did, we would add an extra scope
to put this in SPARQL, ShpC would have the following scope
select ?this where { [] a ex:Person ; p1/p2 ?this }

if we want to add recursion into this what we could do is something like
the following
ShpA has an explicit scope with scopeClass [ a ex:Person]  and 1 implicit
scope [a ex:Person] / (p1 / p2 / p3 )+
ShpB has no explicit scope and 1 implicit scope: [a ex:Person] / (p1 / p2 /
p3 )* / p1
ShpC has no explicit scope and 1 implicit scope: [a ex:Person] / (p1 / p2 /
p3 )* / p1 / p2

As I said, this is just a draft idea for very simple recursion in simple
shape definitions.
I have not yet tested it or thought how this will behave in nested AND / OR
(I think NOT is out of the question anyway), I just wanted to share this
and get you feedback if it is worth exploring more

Best
Dimitris


-- 
Dimitris Kontokostas
Department of Computer Science, University of Leipzig & DBpedia Association
Projects: http://dbpedia.org, http://rdfunit.aksw.org, http://
http://aligned-project.eu
Homepage:http://aksw.org/DimitrisKontokostas
Research Group: AKSW/KILT http://aksw.org/Groups/KILT
Received on Thursday, 3 March 2016 07:55:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:30:30 UTC