On 9/29/2015 23:11, Roger Sacilotto wrote:
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.

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.

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?

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

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