Sparql constraints

39 views
Skip to first unread message

Julie Budaher

unread,
Nov 5, 2021, 8:03:24 PM11/5/21
to TopBraid Suite Users
Hi,
Sorry for the basic question , but I am eventually new to this domain.
I am confused about the difference between a sparql query and a sparql constraint that is added in order to inference new triples. I have sparql queries that I need to put them in the form of shacl rules in order to make inference, and when I add the sparql query in sh:sparql, I am getting an error saying:Error: value must be an instance of sparql constraint. Can someone explain to me, please, how can I use these sparql queries as sparql constraints ? Thank you in advance

Holger Knublauch

unread,
Nov 5, 2021, 9:26:11 PM11/5/21
to topbrai...@googlegroups.com

Hi Julie,

I assume you want to instantiate sh:SPARQLRule https://w3c.github.io/shacl/shacl-af/#SPARQLRule

and link a class/shape with that rule using sh:rule. sh:sparql is used for constraints, not inference rules.

You can see an example of this in the datacube.shapes.ttl file:

qb:ComponentPropertyRuleShape
  a sh:NodeShape ;
  rdfs:comment "A SHACL rule that can be used to infer additional triples that copies all values of the sub-properties of qb:componentProperty into qb:componentProperty itself. This is needed because many constraints here only reference qb:componentProperty." ;
  sh:rule [
      a sh:SPARQLRule ;
      sh:construct """CONSTRUCT {
    ?subject qb:componentProperty ?object .
}
WHERE {
    ?subject qb:attribute|qb:dimension|qb:measure|qb:measureDimension ?object .
}""" ;
      sh:order 0 ;
      sh:prefixes <http://topbraid.org/datacube> ;
    ] ;
  sh:targetNode sh:this ;
.

and many more in the file owl2shacl.ttl

One area where every newcomer seems to trip over is how to use sh:prefixes. To get started and keep it simple you may want to just place them as PREFIX declarations into each rule. Otherwise, https://www.w3.org/TR/shacl/#sparql-prefixes

Holger

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/530d8d3e-0dec-40c0-bd01-ead87639f57fn%40googlegroups.com.

Julie Budaher

unread,
Nov 7, 2021, 6:47:12 AM11/7/21
to TopBraid Suite Users
Hi Holger,
Thank you for your response and the detailed information.
Julie
Reply all
Reply to author
Forward
0 new messages