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.  But - this 
may be a good time to ask a related question - what is the right method for 
processing shape triples vs. data triples when they are in different files? 
 I tried the following:


        // Load the main data model
        Model dataModel = JenaUtil.createMemoryModel();
        
dataModel.read(getClass().getResourceAsStream("/one-spike-clip-1.ttl"), 
"urn:dummy", FileUtils.langTurtle);

        // Load the shapes for the data
        Model 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 registered
        SHACLFunctions.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 results
        Model results = 
ModelConstraintValidator.get().validateModel(dataset, shapesGraphURI, null, 
false, null);


I thought that merging my SHACL triples with the metamodel would be 
sufficient, but the validator failed to detect a violation that I put into 
the data file. I did get the validator to detect the violation if I 
combined the two files into the dataModel and then follow the previous 
code. What is the recommended method for this pattern?

Thanks,

Roger 


On Monday, September 28, 2015 at 7:20:32 PM UTC-4, Holger Knublauch wrote:
>
> 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
>
>

-- 
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.

Reply via email to