Re: SHACL with RDF Datasets

Hi Edmond,

yes we have seen the same requirement. In TopBraid we are supporting this constraint component

tosh:ShapeInGraphConstraintComponent
  a sh:ConstraintComponent ;
  dash:propertySuggestionGenerator tosh:DeleteTripleSuggestionGenerator ;
  rdfs:comment "A constraint component that can be used to verify that the value nodes have a given shape, where the shape validation is executed in a given graph. This can, for example, be used to verify that a given value is declared as an instance of a given class in some specified (not imported) graph." ;
  rdfs:label "Shape in graph constraint component" ;
  sh:labelTemplate "Values must have shape {$shapeInGraph} defined in graph {$graph}" ;
  sh:message "Value does not have shape {$shapeInGraph} defined in graph {$graph}" ;
  sh:parameter [
      sh:path tosh:graph ;
      sh:nodeKind sh:IRI ;
    ] ;
  sh:parameter [
      sh:path tosh:shapeInGraph ;
      sh:nodeKind sh:BlankNodeOrIRI ;
    ] ;
  sh:validator [
      a sh:SPARQLAskValidator ;
      sh:ask """ASK {
    GRAPH $graph {
    FILTER tosh:hasShape($value, $shapeInGraph)
  }
}""" ;
      sh:prefixes <http://topbraid.org/tosh> ;
    ] ;
.

and then have a custom dash:editor that selects available values using

SELECT DISTINCT ?remoteValue ?remoteLabel
                WHERE {
                    $focusNode a ?type .
                    ?type rdfs:subClassOf* ?class .
                    ?nodeShape sh:targetClass? ?class .
                    ?nodeShape sh:property ?ps .
                    ?ps sh:path $predicate .
                    ?ps tosh:graph ?graph .
                    ?ps tosh:shapeInGraph/sh:class ?remoteClass .
                    GRAPH ?graph {
                        ?remoteType rdfs:subClassOf* ?remoteClass .
                        ?remoteValue a ?remoteType .
                        BIND (ui:label(?remoteValue) AS ?remoteLabel) .
                    }
                } ORDER BY ?remoteLabel

This is slightly more general than just class-in-graph, but I think a pure class-in-graph constraint for 1.2 could make sense, maybe even as second parameter to sh:ClassConstraintComponent.

If you haven't done so, why don't you record the problem statement and suggested solution at https://github.com/w3c/shacl/issues

Holger


> On 26 Nov 2024, at 6:22 AM, Edmond Chuc <edmond@kurrawong.ai> wrote:
> 
> Hi all,
> 
> I'm wondering whether there's been any new thoughts or development to this original email <https://lists.w3.org/Archives/Public/public-shacl/2019Jul/0003.html> around extending SHACL to work with RDF datasets.
> 
> My use case is to acquire values that satisfy both the sh:class​ and sh:node​ definitions from a specific named graph and use these values in a SHACL UI autocomplete widget. I'm using shx:targetGraph​ from Extending SHACL to RDF Datasets <https://afs.github.io/shacl-datasets.html>. Please see the example property shape below.
> 
> Currently, SHACL operates on a single data graph. Without RDF dataset support, implementing a general SHACL UI tool capable of editing data across data graphs becomes challenging.
> 
> Would extending SHACL to support RDF datasets be a candidate for the next SHACL version?
> 
> Alternatively, is there another technique or approach I could consider?
> Looking forward to any thoughts or suggestions!
> 
> Cheers,
> 
> Edmond
> 
>     :Dataset-keywords a sh:PropertyShape ;
>         sh:name "Search Words" ;
>         sh:path sdo:keywords ;
>         sh:class skos:Concept ;
>         shx:targetGraph <urn:graph:vocabs> ;
>         sh:node [
>             sh:property [
>                 sh:path skos:inScheme ;
>                 sh:hasValue <https://linked.data.gov.au/def/GSWA-vocabulary-themes> ;
>             ] ;
>             sh:property [
>                 sh:path skos:prefLabel ;
>                 dash:propertyRole dash:LabelRole ;
>             ] ;
>         ] ;
>         sh:order 3 ;
>         sh:group :Dataset-metadata-group ;
>     .
> 
> Edmond Chuc
> Knowledge Graph Senior Developer
> KurrawongAI
>       
> 
> edmond@kurrawong.ai <>
>  https://kurrawong.ai <https://kurrawong.ai/>
>  
>  
>  
> 
> 
> 

Received on Tuesday, 26 November 2024 08:55:15 UTC