- From: Ruben Taelman <ruben.taelman@ugent.be>
- Date: Tue, 29 Aug 2017 09:21:55 +0200
- To: Holger Knublauch <holger@topquadrant.com>, public-rdf-shapes@w3.org
- Message-ID: <etPan.59a51619.314d3e59.140@ugent.be>
Dear Holger,
Thank you for your answer.
I'll try to clarify my use case a bit more.
The operation I mentioned before represents an API call, which is described using the Hydra vocabulary [1].
At the moment, we describe triple pattern queries as follows:
_:search hydra:template "http://example.org{?subject,predicate,object}";
hydra:variableRepresentation hydra:ExplicitRepresentation;
hydra:mapping _:subject, _:predicate, _:object;
_:subject hydra:variable "subject";
hydra:property rdf:subject.
_:predicate hydra:variable "predicate";
hydra:property rdf:predicate.
_:object hydra:variable "object";
hydra:property rdf:object.
Next to that, we also want to describe the RDF results of this API call,
where the _:subject, _:predicate and _:object variables are used as parameters.
Which we could indeed do using SHACL-SPARQL as you suggested:
_:search hydra:resultShape ex:findMatchingTriples.
ex:findMatchingTriples
sh:parameter [
sh:path _:subject ;
sh:order 0 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] ;
sh:parameter [
sh:path _:predicate ;
sh:order 1 ;
sh:nodeKind sh:IRI ;
] ;
sh:parameter [
sh:path _:object ;
sh:order 2 ;
] ;
sh:propertyValidator [
a sh:SPARQLSelectValidator ;
sh:select """
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .
}
"""
] .
This seems like a solution that would definitely work,
but I'm just wondering what the advantage of this SHACL-based definition
would be compared to a SPIN-based definition, such as the following:
_:search hydra:resultShape ex:findMatchingTriplesAlt.
ex:findMatchingTriplesAlt
my:hasParameters ( _:subject, _:predicate, _:object );
a sp:Select;
sp:resultVariables ( _:subject, _:predicate, _:object );
sp:where ([
sp:subject _:subject;
sp:predicate _:predicate;
sp:object _:object
]).
One obvious advantage of SHACL is that it's a W3C recommendation.
But to me, it seems like SPIN might be more fitting to our use case,
as there is an explicit RDF-based link between the parameters of the API call
and the parameters within the query.
Furthermore, this might enable other RDF-based techniques (such as reasoners)
to take advantage of this query structure, which would not be possible with the SHACL definition as the query is text-based.
What is your opinion on using SPIN or SHACL in this case?
Kind regards,
Ruben Taelman
[1] http://www.hydra-cg.com/spec/latest/core/
On 29 August 2017 at 01:28:10, Holger Knublauch (holger@topquadrant.com) wrote:
Hi Ruben,
it is unclear to me what exactly you are attempting to represent. Below you present an outline for a solution but the problem statement isn't clear. Could you elaborate a bit?
Note that the SHACL vocabulary (see TTL file) includes the class sh:Parameterizable that can be used as superclass of all kinds of "templates". For example to state that something takes three arguments, you could do
my:Operation rdfs:subClassOf sh:Parameterizable .
ex:findMatchingTriples
a my:Operation ;
sh:parameter [
sh:path ex:subject ;
sh:order 0 ;
sh:nodeKind sh:BlankNodeOrIRI ;
] ;
sh:parameter [
sh:path ex:predicate ;
sh:order 1 ;
sh:nodeKind sh:IRI ;
] ;
sh:parameter [
sh:path ex:object ;
sh:order 2 ;
] ;
...
(and then attach whatever you like as other triples to the ex:findMatchingTriples - in the case of SHACL-SPARQL there are SPARQL queries, in the case of SHACL-JS there are JS snippets).
The above may be on the wrong meta-level, but as I said I don't really understand your use case yet.
Regards
Holger
On 28/08/2017 21:41, Ruben Taelman wrote:
Dear all,
I have a question regarding the potential use of SHACL for a certain use-case,
and I'm wondering if someone here can help me identify whether or not SHACL is a good solution for this.
I am looking for a vocabulary that can declaratively describe RDF results
of a certain operation, based on certain parameters.
For example, assume the following operation can evaluate triple pattern queries:
findMatchingTriples(subject, predicate, object)
As far as I can see, SHACL doesn't provide a way to bind 'variables' to nodes in a shape.
The closest I have come to describing such a triple pattern operation
is using the following (invalid) SHACL shape:
_:shape a sh:NodeShape;
sh:targetNode _:subject;
sh:property [
sh:path _:predicate;
sh:hasValue _:object.
].
_:subject, _:predicate and _:object refer to the variable parameters of the operation.
I assume I need some kind of abstraction layer above SHACL,
that basically 'instantiates' SHACL shapes based on certain parameters.
So my question is:
is such an abstraction already possible in some form, or are there future plans for something like this?
Or would you suggest using a SPARQL-based vocabulary for this, such as SPIN,
as I don't really need SHACL's validation and constraint checking-features.
Kind regards,
Ruben Taelman
Received on Tuesday, 29 August 2017 07:22:23 UTC