RDF data validation is the process of checking a (data) graph against constraints from a schema definition. In the Shapes Constraint Language (SHACL), constraints are themselves expressed in a RDF syntax, in so-called shapes graphs. SHACL-based validation engines can (among others) be used to reject data that contains malformed instances of a class (such as a Person with three parents). Some engines can furthermore suggest how to fix malformed data. Since any data that is added into an organization’s knowledge base should satisfy certain quality contracts, constraint validation is a mission-critical task.

The TopBraid platform includes comprehensive support for SHACL, including rich user interfaces for editing SHACL-based data models, see our earlier blog post on Using SHACL Data Constraints in the TopBraid EDG. In addition to these interactive features, the TopBraid Live product (which is also part of EVN and EDG and, for testing purposes, in TopBraid Composer Maestro Edition) includes a simpler web service for programmatic access to the SHACL validation engine. This feature was introduced with version 5.3.1. In its most basic form, the validation servlet can be called as a GET or POST request against the URL

http://localhost:8083/tbl/shaclValidation

which takes the following parameters:

  • dataGraph (source code of data graph) or dataGraphURL (to load from a URL)
  • dataGraphFormat (“ttl” (default) or “json” or “rdfxml”)
  • dataGraphImports (true to process owl:imports in data graph)
  • shapesGraph (source code of shapes graph) or shapesGraphURL (to load from a URL)
  • shapesGraphFormat (“ttl” (default) or “json” or “rdfxml”)
  • shapesGraphImports (true to process owl:imports in shapes graph)
  • validateShapes (true to also validate any shape definitions in the data graph)
  • output (“ttl” (default) or “json” (for JSON-LD) or “html”)

The servlet also comes with a simple HTML interface:

SHACLValidationPage

This produces a results page listing details on all constraint violations:

SHACLValidationResults