@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 ----------------------------------------------------------------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 validateavids:TestShapea 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:Test2a 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" .
"Values must be instances of sh:PropertyConstraint"^^<http://www.w3.org/2001/XMLSchema#string> ;[] ;[] ;] .
--
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 topbrai...@googlegroups.com
---
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.
For more options, visit https://groups.google.com/d/optout.
// Load the main data modelModel dataModel = JenaUtil.createMemoryModel();dataModel.read(getClass().getResourceAsStream("/one-spike-clip-1.ttl"), "urn:dummy", FileUtils.langTurtle);// Load the shapes for the dataModel schemaModel = JenaUtil.createMemoryModel();schemaModel.read(getClass().getResourceAsStream("/one-spike-shacl.ttl"), "urn:dummy", FileUtils.langTurtle);// Load the shapes Model (here, includes the dataModel because that has templates in it)Model shaclModel = JenaUtil.createDefaultModel();InputStream is = getClass().getResourceAsStream("/etc/shacl.shacl.ttl");shaclModel.read(is, SH.BASE_URI, FileUtils.langTurtle);MultiUnion unionGraph = new MultiUnion(new Graph[] {shaclModel.getGraph(),schemaModel.getGraph()});Model shapesModel = ModelFactory.createModelForGraph(unionGraph);// Note that we don't perform validation of the shape definitions themselves.// To do that, activate the following line to make sure that all required triples are present:// dataModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel);// Make sure all sh:Functions are registeredSHACLFunctions.registerFunctions(shapesModel);// Create Dataset that contains both the main query model and the shapes model// (here, using a temporary URI for the shapes graph)URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString());Dataset dataset = ARQFactory.get().getDataset(dataModel);dataset.addNamedModel(shapesGraphURI.toString(), shapesModel);// Run the validator and print resultsModel results = ModelConstraintValidator.get().validateModel(dataset, shapesGraphURI, null, false, null);
Hi Holger,
Thanks, your response did help. I'm still a little confused on the validation of the ShapeClass - I already did as you suggested by merging the datamodel with the SHACL metamodel, the Java class is a copy of the ValidateSquareExampleTest class with a different input file name, so ShapeClass should have been processed as a subclass of Shape.
@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 ----------------------------------------------------------------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
avidtx:Test a rdfs:Class .
avids:TestShapea sh:Shape ;sh:scopeClass avidtx:Test ;sh:property [
a sh:PropertyConstraint ;
sh:predicate dc:title ;sh:datatype sh:text ;sh:minCount 1 ;sh:maxCount 1 ;
sh:filterShape [a sh:Shape ;sh:predicate avidc:isComplete ;sh:hasValue "true"^^xsd:boolean ;] ;] .#succeed
<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0963> a avidtx:Test ;
dc:title "Test Title 1" ;avidc:isComplete "true"^^xsd:boolean .#succeed, should not fail dc:title constraint because avidc:isComplete is not true<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0973> a avidtx:Test ;avidc:isComplete "false"^^xsd:boolean .#fail, dc:title constraint is violated<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0983> a avidtx:Test ;avidc:isComplete "true"^^xsd:boolean .
Yes, the shapes graph would know that sh:ShapeClass is a subclass of sh:Shape, yet the data graph does not know that unless you also merge the SHACL system vocabulary into the data graph. The SHACL engine uses the shapes graph to figure out which constraints to run, but it relies on the data graph to contain the relevant rdfs:subClassOf triples to find all instances of the classes affected by the constraints.
All this requires better explanations and tool support - apologies if this is very early in the process.
#succeed<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0963> a avidtx:Test ;dc:title "Test Title 1" ;avidc:isComplete "true"^^xsd:boolean .
#succeed, should not fail dc:title constraint because avidc:isComplete is not true<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0973> a avidtx:Test ;avidc:isComplete "false"^^xsd:boolean .
#fail, dc:title constraint is violated<urn:avid:object:17324310-1787-4a7d-BB62-4179CABF0983> a avidtx:Test ;avidc:isComplete "true"^^xsd:boolean .
The third resource fails validation as expected, but the second one fails, too, and I can't figure out why. The filter shape should prevent the dc:title property constraint from being checked, correct? I don't know what the error is here, do you have any advice?
Thanks,
Roger
On Tuesday, September 29, 2015 at 11:16:52 PM UTC-4, Holger Knublauch wrote:Yes, the shapes graph would know that sh:ShapeClass is a subclass of sh:Shape, yet the data graph does not know that unless you also merge the SHACL system vocabulary into the data graph. The SHACL engine uses the shapes graph to figure out which constraints to run, but it relies on the data graph to contain the relevant rdfs:subClassOf triples to find all instances of the classes affected by the constraints.
All this requires better explanations and tool support - apologies if this is very early in the process.
The ValidateSquareExample was already doing the right thing AFAIK - it was just using the square file as data graph. So maybe there is something else going on that I don't see. Have you tried to run your file through TBC 5.0.1 validation? Otherwise, feel free to send me the files.
Holger