Shacl Validation with property constraint to sh:class union

24 views
Skip to first unread message

Martin Jergler

unread,
Nov 15, 2019, 3:38:10 AM11/15/19
to TopBraid Suite Users
Hi,

with TopBraid Composer I created a property constraint with a sh:class definition which comprises a union of classes (see figure below).
However, when I want to validate my instance data against the defined shape using the shacl.ValidationUtil it results in a error because the shacl file is serialized using blank nodes.
It seems to me that the ValidationUtil cannot cope with blank nodes in the SHACL model. 

Does anybody know of a solution to this problem?


Unbenannt.PNG



















Thanks a lot
Martin

dprice

unread,
Nov 15, 2019, 4:08:35 AM11/15/19
to topbrai...@googlegroups.com
Hi Martin,

My reading of the SHACL spec is that the union is not legal SHACL. See https://www.w3.org/TR/shacl/#constraints-section where I see: sh:class or sh:datatype : rdfs:Resource

I made a small example and find that what you tried to do sort of works. Composer actually tells me that the property shape union is invalid, as I thought per SHACL spec section 2. Shapes and Constraints linked above, but it does still tell me the instance min/max was invalid. 

Here’s the validation report:



Here’s the example tested with 6.3 Beta:

# prefix: unnamed

@prefix dash: <http://datashapes.org/dash#> .
@prefix unnamed: <http://example.org/unnamed#> .

  a owl:Ontology ;
  owl:imports <http://datashapes.org/dash> ;
  owl:versionInfo "Created with TopBraid Composer" ;
.
unnamed:PropertyShape_1
  a sh:PropertyShape ;
  sh:path unnamed:Property_1 ;
  sh:class [
      a owl:Class ;
      owl:unionOf (
          unnamed:Thing_1
          unnamed:Thing_2
        ) ;
    ] ;
  sh:maxCount 3 ;
  sh:minCount 3 ;
.
unnamed:Property_1
  a rdf:Property ;
  rdfs:domain unnamed:Thing_3 ;
.
unnamed:Thing_1
  a owl:Class ;
  a sh:NodeShape ;
  rdfs:subClassOf owl:Thing ;
.
unnamed:Thing_1_1
  a unnamed:Thing_1 ;
.
unnamed:Thing_2
  a owl:Class ;
  a sh:NodeShape ;
  rdfs:subClassOf owl:Thing ;
.
unnamed:Thing_3
  a owl:Class ;
  a sh:NodeShape ;
  rdfs:subClassOf owl:Thing ;
  sh:property unnamed:PropertyShape_1 ;
.
unnamed:Thing_3_1
  a unnamed:Thing_3 ;
  unnamed:Property_1 unnamed:Thing_1_1 ;
.


WRT a solution - One approach is to make a superclass of the three classes in the union.

Cheers,
David

On 15 Nov 2019, at 08:38, Martin Jergler <martin....@gmail.com> wrote:

Hi,

with TopBraid Composer I created a property constraint with a sh:class definition which comprises a union of classes (see figure below).
However, when I want to validate my instance data against the defined shape using the shacl.ValidationUtil it results in a error because the shacl file is serialized using blank nodes.
It seems to me that the ValidationUtil cannot cope with blank nodes in the SHACL model. 

Does anybody know of a solution to this problem?


<Unbenannt.PNG>



















Thanks a lot
Martin

--
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/49930160-0796-41af-89e5-0d41e43b3937%40googlegroups.com.
<Unbenannt.PNG>


Martin Jergler

unread,
Nov 15, 2019, 5:38:21 AM11/15/19
to topbrai...@googlegroups.com
Hi David,

thanks a lot for the quick response.
You are right, a superclass works and actually fits what we want to achieve. Thumbs up!

Thanks again and best regards
Martin

Irene Polikoff

unread,
Nov 15, 2019, 7:26:16 AM11/15/19
to topbrai...@googlegroups.com
Yes, Martin’s example had a malformed SHACL shape. 

As per the spec, the value of sh:class must be a URI. In the below example, the value is a blank node.

sh:class [
      a owl:Class ;
      owl:unionOf (
          unnamed:Thing_1
          unnamed:Thing_2
        ) ;
    ] ;


The behavior of the SHACL engine is not defined if a shape is malformed.

You should not be using OWL Manchester syntax to specify values for SHACL constraints, targets, etc.

SHACL has sh:or constraint component.

The correct SHACL expression would be:

sh:or (
      [
        sh:class unnamed:Thing_1 ;
      ]
      [
        sh:class unnamed:Thing_1 ;
      ]
    ) ;

Creating a parent class for the three subclasses also works and is simpler.

On Nov 15, 2019, at 5:38 AM, Martin Jergler <martin....@gmail.com> wrote:

Hi David,

thanks a lot for the quick response.
You are right, a superclass works and actually fits what we want to achieve. Thumbs up!

Thanks again and best regards
Martin

Am Fr., 15. Nov. 2019 um 10:08 Uhr schrieb dprice <dpr...@topquadrant.com>:
Hi Martin,

My reading of the SHACL spec is that the union is not legal SHACL. See https://www.w3.org/TR/shacl/#constraints-section where I see: sh:class or sh:datatype : rdfs:Resource

I made a small example and find that what you tried to do sort of works. Composer actually tells me that the property shape union is invalid, as I thought per SHACL spec section 2. Shapes and Constraints linked above, but it does still tell me the instance min/max was invalid. 

Here’s the validation report:

<Screen Shot 2019-11-15 at 09.00.34.png>
Reply all
Reply to author
Forward
0 new messages