Class ValidationUtil


  • public class ValidationUtil
    extends Object
    Convenience methods to perform SHACL validation. These methods are provided for convenience of simple use cases only but are often not the most efficient way of working with SHACL. It is typically better to separate the creation of the ShapesGraph object from the ValidationEngine because the ShapesGraph can be reused across multiple validations, and serves as a "pre-compiled" data structure that is expensive to rebuild for each run. Having separate calls also provides access to the other functions of the ValidationEngine object, such as validateNode and getValidationReport.
    Author:
    Holger Knublauch
    • Constructor Detail

      • ValidationUtil

        public ValidationUtil()
    • Method Detail

      • createValidationEngine

        public static ValidationEngine createValidationEngine​(org.apache.jena.rdf.model.Model dataModel,
                                                              org.apache.jena.rdf.model.Model shapesModel,
                                                              boolean validateShapes)
      • ensureToshTriplesExist

        public static org.apache.jena.rdf.model.Model ensureToshTriplesExist​(org.apache.jena.rdf.model.Model shapesModel)
      • validateModel

        public static org.apache.jena.rdf.model.Resource validateModel​(org.apache.jena.rdf.model.Model dataModel,
                                                                       org.apache.jena.rdf.model.Model shapesModel,
                                                                       boolean validateShapes)
        Validates a given data Model against all shapes from a given shapes Model. If the shapesModel does not include the system graph triples then these will be added. Entailment regimes are applied prior to validation.
        Parameters:
        dataModel - the data Model
        shapesModel - the shapes Model
        validateShapes - true to also validate any shapes in the data Model (false is faster)
        Returns:
        an instance of sh:ValidationReport in a results Model
      • validateModel

        public static org.apache.jena.rdf.model.Resource validateModel​(org.apache.jena.rdf.model.Model dataModel,
                                                                       org.apache.jena.rdf.model.Model shapesModel,
                                                                       ValidationEngineConfiguration configuration)
        Validates a given data Model against all shapes from a given shapes Model. If the shapesModel does not include the system graph triples then these will be added. Entailment regimes are applied prior to validation.
        Parameters:
        dataModel - the data Model
        shapesModel - the shapes Model
        configuration - configuration for the validation engine
        Returns:
        an instance of sh:ValidationReport in a results Model