Hi Roger,
what you are experiencing is a side effect of which triples you are
giving as input to the validation. The valueClass of sh:property is
sh:PropertyConstraint, yet the file only has an untyped blank node. This
is perfectly valid syntactic sugar in SHACL, yet it means that for
validation purposes the additional triple(s) should be made visible. You
can uncomment the following line and it will work:
dataModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel);
This is (temporarily) adding the rdf:type triple for the
sh:PropertyConstraint.
The situation is different with sh:ShapeClass, which is declared to be a
subclass of sh:Shape *in the SHACL metamodel graph*. However, the
constraint on sh:property is defined for sh:Shape only, and in order to
apply it to the data graph too, you need to make sure that the data
graph has the SHACL metamodel (and its subclass of triple) as a
sub-graph. You'd need to create a MultiUnion graph consisting of your
own data plus the SHACL metamodel and pass this into the validation
engine. Without that triple, the system will not check sh:ShapeClass at
all, because it doesn't know that it's a subclass of sh:Shape in the
data graph.
HTH
Holger
On 9/29/2015 1:49, Roger Sacilotto wrote:
Hello all,
I downloaded the shacl Java library from GitHub, but I'm having a
problem with what should be a simple example.
I copied the SquareExample test, and tried run the validator with a
very simple model. After playing with it for some time, it seems that
the validator fails if I'm defining a sh:Shape resource that has a
sh:scopeClass property, but works with a sh:ShapeClass resource.
Here is the input:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix avidc: <http://meta.avid.com/vocab/common#> .
@prefix avidtx: <http://meta.avid.com/class#> .
@prefix avids: <http://meta.avid.com/shapes#> .
@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix dc: <http://purl.org/dc/1.1/elements/>
@prefix xmpDM: <http://ns.adobe.com/xmp/1.0/DynamicMedia/>
# The sh:Graph
----------------------------------------------------------------
<http://avid.com/examples/test>
a sh:Graph ;
sh:shapesGraph <http://www.w3.org/ns/shacl> ;
rdfs:label "SHACL Test" ;
rdfs:comment "A simple example model." ;
.
# TestShape example does not validate
avids:TestShape
a sh:Shape ;
sh:scopeClass avidtx:Test ;
sh:property [
sh:predicate dc:title ;
sh:datatype sh:text ;
sh:minCount 1 ;
sh:maxCount 1 ;
] .
<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0963> a avidtx:Test ;
dc:title "Test Title 1" .
avidtx:Test a rdfs:Class .
# Test2 example validates (changed Shape to ShapeClass)
avids:Test2
a sh:ShapeClass ;
sh:property [
sh:predicate dc:title ;
sh:datatype sh:text ;
sh:minCount 1 ;
sh:maxCount 1 ;
] .
<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0964> a
avidtx:Test2 ;
dc:title "Test Title 2" .
The output from the validator is as follows:
[ a <http://www.w3.org/ns/shacl#ValidationResult> ;
<http://www.w3.org/ns/shacl#focusNode>
<http://meta.avid.com/shapes#TestShape> ;
<http://www.w3.org/ns/shacl#message>
"Values must be instances of
sh:PropertyConstraint"^^<http://www.w3.org/2001/XMLSchema#string> ;
<http://www.w3.org/ns/shacl#object>
[] ;
<http://www.w3.org/ns/shacl#predicate>
<http://www.w3.org/ns/shacl#property> ;
<http://www.w3.org/ns/shacl#severity>
<http://www.w3.org/ns/shacl#Violation> ;
<http://www.w3.org/ns/shacl#sourceConstraint>
[] ;
<http://www.w3.org/ns/shacl#sourceShape>
<http://www.w3.org/ns/shacl#Shape> ;
<http://www.w3.org/ns/shacl#sourceTemplate>
<http://www.w3.org/ns/shacl#AbstractValueClassPropertyConstraint> ;
<http://www.w3.org/ns/shacl#subject>
<http://meta.avid.com/shapes#TestShape>
] .
I'm hoping that I have made a simple mistake, is there anything
additional I need to declare to fix the violation?
Thanks,
Roger
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise
Vocabulary Network (EVN), Reference Data Manager (RDM), TopBraid
Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web
Pages and SPIN.
To post to this group, send email to [email protected]
---
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 [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Group "TopBraid
Suite Users", the topics of which include Enterprise Vocabulary Network (EVN),
Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight,
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.