ASHACL: Alternative Shapes Constraint Language

02/06/2017 ∙ by Peter F. Patel-Schneider, et al. ∙ Nuance Communications 0

ASHACL, a variant of the W3C Shapes Constraint Language, is designed to determine whether an RDF graph meets some conditions. These conditions are grouped into shapes, which validate whether particular RDF terms each meet the constraints of the shape. Shapes are themselves expressed as RDF triples in an RDF graph, called a shapes graph.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

As of February 2017 the W3C Shapes Constraint Language (SHACL) [5] is under development by the W3C Data Shapes Working Group. The design document for SHACL, Shapes Constraint Language (SHACL), as of this time is available at https://www.w3.org/TR/2017/WD-shacl-20170202/

SHACL is divided into two parts, SHACL Core and SHACL-SPARQL.

SHACL Core has two separate specifications; a complete normative specification in text and a partial informative specification as a mapping to an extension of SPARQL [4]. The specification via a mapping to SPARQL uses a version of pre-binding defined in SHACL. The use of pre-binding has caused continual problems in SHACL. Sometimes the definition of pre-binding produces many constructs whose mapping specification diverges from the text specfication. Sometimes, including now, the definition of pre-binding has problems making it unsuitable for use in all or part of SHACL. The text specification of SHACL Core suffers from a lack of rigour, resulting in a specification that can be read in multiple ways.

SHACL-SPARQL depends on a mapping to SPARQL that has the same problems as the partial mapping for SHACL Core but the mapping is normative for SHACL-SPARQL.

The syntax of SHACL Core is unnecessarily complex and fragile. Certain constructs can be used in some places but not in other very simlar places. There are constructs that are limited versions of other constructs. There are multiple influences on how certain constructs behave.

This document contains a specification for ASHACL, an alternative version of the validating portion of SHACL Core using many parts of the specification of SHACL Core [5].

The major syntax difference between ASHACL and the current version of SHACL Core is to unify the various kinds of shapes in SHACL Core into a single notion of a shape. The single property sh:path then controls how to determine value nodes. This results in a simpler and more uniform language.

Another significant difference is how validation results and reports are defined. This eliminates the problematic procedural dependencies in SHACL Core and correctly specifies what needs to be contained in a validation report.

A third significant difference is the removal of the informative SPARQL specifications for many SHACL Core constructs. This eliminates the informative dependency on pre-binding as well as removing a source of divergence in the specification.

The specification of ASHACL here is in text form with dependence on only a few SPARQL functions. The specification of ASHACL here has been carefully constructed to be precise and well-defined, eliminating the problems with imprecise and poorly constructed parts of the current specification of SHACL.

Because ASHACL is a variant of SHACL, much of the desgin of ASHACL here is taken fromd SHACL [5]. Some of the wording here has as source wording in Shapes Constraint Language (SHACL) [5].

2 Examples

Here are several simple informative examples of ASHACL shapes graphs along with English glosses of what they do.

Check that all ASHACL instances of ex:Person have all their values for ex:child be ASHACL instances of ex:Person.

@prefix sh:   <http://example.org/ns/shacl\#> .
@prefix ex:   <http://example.org/example/> .
ex:s a sh:Shape ;
  sh:targetClass ex:Person ;
  sh:shape [ sh:path ex:child ;
             sh:class ex:Person ] .

Check that all ASHACL instances of ex:Person have all their values for ex:child be ASHACL instances of ex:Person, using only one shape.

@prefix sh:   <http://example.org/ns/shacl\#> .
@prefix ex:   <http://example.org/example/> .
ex:s a sh:Shape ;
  sh:targetClass ex:Person ;
  sh:path ex:child ;
  sh:class ex:Person .

Check that all subjects and objects of ex:parent RDF triples are ASHACL instances of ex:Animal.

@prefix sh:   <http://example.org/ns/shacl\#> .
@prefix ex:   <http://example.org/example/> .
ex:s a sh:Shape ;
  sh:targetSubjectsOf ex:parent ;
  sh:targetObjectsOf ex:parent ;
  sh:class ex:Animal .

3 Basic Terminology

Throughout the remainder of this document, IRIs are written as Turtle [6] prefixed names, using the following mapping of prefixes to namespaces:

Terminology that is linked to portions of RDF 1.1 Concepts and Abstract Syntax [2] is used in ASHACL as defined there. Terminology that is linked to portions of SPARQL 1.1 Query Language [4] is used in ASHACL as defined there. A single linkage is sufficient to provide a definition for all occurrences of a particular term in this document.

Definitions are complete within this document, i.e., if there is no rule to make a some situation true in this document then the situation is false. Definitions, or partial definitions, have the phrase being defined in bold. Some definitions are dispersed throughout the document. For these terms each portion of the definition has the phrase being defined in bold.

Property:

A property is an IRI.

Value:

An RDF term has value for property in an RDF graph if there is an RDF triple in with subject , predicate , and object .

An RDF term has value for SPARQL property path expression in an RDF graph if there is a solution mapping in the result of the SPARQL query SELECT ?s ?o WHERE { ?s ?o } on that binds ?s to and ?o to , where is SPARQL surface syntax for .

Path:

A path in an RDF graph from RDF term to RDF term is a finite sequence of RDF triples in such that the subject of the first RDF triple is , the object of the last RDF triple is , and the object of each RDF triple except the last is the subject of the next.

ASHACL List:

An ASHACL list in an RDF graph is an IRI or a blank node that is either rdf:nil (provided that rdf:nil has no value for either rdf:first or rdf:rest in ), or has exactly one value for rdf:first in and exactly one value for rdf:rest in that is also an ASHACL list in and there is no non-empty path in from the list back to itself where the predicates of the RDF triples in the path are each rdf:rest.

The members of any ASHACL list except rdf:nil in an RDF graph consist of its value for rdf:first in followed by the members in of its value for rdf:rest in . The ASHACL list rdf:nil has no members in any RDF graph.

ASHACL Instance and ASHACL Type:

An RDF term is an ASHACL instance of an RDF term in an RDF graph if there is a path in from to where the predicate of the first RDF triple in the path is rdf:type and the predicates of any other RDF triples in the path are rdfs:subClassOf.

An RDF term has an RDF term as ASHACL type in an RDF graph if is an ASHACL instance of in .

Data Graph:

A data graph is any RDF graph.

4 ASHACL Property Paths

ASHACL uses an RDF encoding of much of SPARQL property paths.

A blank node is an ill-formed property path in an RDF graph if it has a value for more than one of either rdf:first or rdf:rest, sh:alternativePath, sh:inversePath, sh:zeroOrMorePath, sh:oneOrMorePath, and sh:zeroOrOnePath in .

A blank node is an ill-formed property path in an RDF graph if there is a path in from the node back to itself where the sequence of predicates of the RDF triples in the path matches the regular expression

An RDF term is an ill-formed property path in an RDF graph if it does not satisfy exactly one of the conditions in the mapping below.

The path mapping in an RDF graph of a RDF term that is an ASHACL property path in , , is a SPARQL property path expression defined as follows:

  1. If is an IRI then is PredicatePath().

  2. If is a blank node that is an ASHACL list in that has at least two members in and none of these members are ill-formed property paths in then is SequencePath() where are the members of in , in order.

  3. If is a blank node that has exactly one value for sh:alternativePath in G and that value is an ASHACL list in that has at least two members in and none of the members are ill-formed property paths in then is AlternativePath() where are the members of the list in , in order.

  4. If is a blank node that has exactly one value for sh:inversePath in and is not an ill-formed property path in then is InversePath().

  5. If is a blank node that has exactly one value for sh:zeroOrMorePath in and is not an ill-formed property path in then is ZeroOrMorePath().

  6. If is a blank node that has exactly one value for sh:oneOrMorePath in G and is not an ill-formed property path in then is OneOrMorePath().

  7. If is a blank node that has exactly one value for sh:zeroOrOnePath in G and is not an ill-formed property path in then is ZeroOrOnePath().

If an RDF term is not an ill-formed property path in an RDF graph then it is an ASHACL property path in .

ASHACL property paths in same or different RDF graphs are path-equivalent if their path mappings in their graphs are the same.

5 Validation Results and Validation Reports

The results of ASHACL validation are RDF graphs that report on the results the validation.

A results graph is an RDF graph where every node in that has ASHACL type sh:ValidationResult in meets the following conditions

  • It has sh:ValidationResult as a value for rdf:type in .

  • It has exactly one value for sh:focusNode in .

  • It has at most one value for sh:valueNode in .

  • It has at most one value for sh:resultPath in and this value if present is an ASHACL property path in .

  • It has exactly one value for sh:sourceShape in .

  • It has exactly one value for sh:sourceConstraintComponent in .

  • It has exactly one value for sh:resultSeverity in .

  • Each of its values for sh:resultMessage in is a language-tagged string and each has a different language tag.

  • Each of its values for sh:detail in has ASHACL type sh:ValidationResult in .

  • Each of its values for in where is a list-taking parameter is an ASHACL list in .

A validation result from RDF term , optional RDF term , data graph , constraint that has kind , and shape in shapes graph is a node in a results graph that meets the following conditions

  • It has sh:ValidationResult as a value for rdf:type in .

  • Its sole value for sh:focusNode in is .

  • Its sole value for sh:valueNode in is if is present, otherwise it has no value for sh:valueNode in .

  • Its sole value for sh:resultPath in is an ASHACL property path in that is path-equivalent to the value of for sh:path in if there is one, otherwise it has no value for sh:resultPath in .

  • Its sole value for sh:sourceShape in is .

  • Its sole value for sh:sourceConstraintComponent in is .

  • Its sole value for sh:resultSeverity in is the severity of in .

  • Its values for sh:resultMessage in include any values of for sh:message in .

  • Its values, if any, for in with a non-list-taking parameter of and are the elements of .

  • Its values, if any, for in with a list-taking parameter of and contain for each member of an ASHACL list in whose elements in are the elements of in and no other values.

A results structure is a results graph and a set of nodes from each of which have ASHACL type sh:ValidationResult in . The set of nodes is called the top-level validation results of the results structure.

A results structure contains a top-level validation result from ,,,,, (or ,,,,) if its graph contains a node that is a validation result from ,,,,, (,,,,, respectively) and that node is an element of its top-level validation results.

A validation report for a results structure is any results graph containing at least the RDF triples of plus a new blank node with sh:ValidationReport as a value for rdf:type in ; "false"^^xsd:boolean as sole value for sh:conforms in if has any top-level validation results in and "true"^^xsd:boolean otherwise; and whose set of values for sh:result in is the set of top-level validation results in .

The combination of a multiset of results structures is the union of the graphs of the results structures and the union of their sets of top-level validation results, provided that this is a results structure.

Note: Combination does not use merging so that, for example, validation results and ASHACL property paths do not have to be replicated. Care does need to be taken when different results structures share blank nodes so that invalid validation results or ASHACL property paths do not result.

Note: Validation reports are only required to contain top-level validation results from results graphs, i.e., the results for validating elements of the complete targets of shapes against the shape. Implementations are encouraged to provide interfaces that also retain other validation results and to use the property sh:detail to link from a validation result for a shape to validation results from subsidiary conformance checking such as is required for constraints that have kind sh:ShapeConstraintComponent.

6 Shapes

6.1 Shapes and Shapes Graphs

The explicit shapes of an RDF graph , , is the set of nodes in that

  1. have sh:Shape as an ASHACL type in , or

  2. are the subject of an RDF triple in with predicate one of the target predicates, sh:targetNode, sh:targetClass, sh:targetSubjectsOf, and sh:targetObjectsOf.

The shapes of an RDF graph , , is the smallest set of RDF terms such that

  1. ,

  2. If and is a triple in wiith a non-list-taking, shape-inducing parameter then .

  3. If , is a triple in with a list-taking, shape-inducing parameter and an ASHACL list in , and is a mamber of in then .

A shapes graph is an RDF graph containing no ill-formed shapes in . Ill-formed shapes are defined throughout the remainder of this document.

If is a shape in an RDF graph with more than one value for sh:severity in then is an ill-formed shape in . The severity of a shape in a shapes graph is its value for sh:severity in , if any, otherwise sh:Violation

If is a shape in an RDF graph with a value for sh:message in that is not either a language-tagged string or a literal with datatype xsd:string then is an ill-formed shape in .

If is a shape in an RDF graph with a value for sh:deactivated in that is not a literal with datatype xsd:boolean then is an ill-formed shape in .

6.2 Constraint Components and Constraints

A constraint component is one of the IRIs so-described in the remainder of this document. Each constraint component has one or more mandatory parameters, each of which is a property. Each constraint component has zero or more optional parameters, each of which is a property. The parameters of a constraint component are its mandatory parameters plus its optional parameters. Some parameters of constraint components are list-taking parameters. Parameters that are not list-taking parameters are non-list-taking parameters. Some parameters of constraint components are shape-inducing parameters.

For a constraint component with mandatory parameters , …, , a shape s in a shapes graph has a constraint that has kind with mandatory parameter values , …, in when has as a value for in . If in has a constraint that has kind in then the optional parameter values of the constraint in are all the where is an optional parameter of and has as a value for in . The parameter values of a constraint are its mandatory parameter values plus its optional parameter values.

6.3 Recursive Shapes and Recursive Shapes Graphs

A shape in an RDF graph refers to shape in if it has as value for some non-list-taking, shape-inducing parameter of some constraint component or as a member of the value for some list-taking, shape-inducing parameter of some constraint component.

A shape in an RDF graph is recursive in if it is related to itself by the transitive closure of the refers relationship in . An RDF graph that contains a shape recursive in is recursive.

6.4 Targets

If is a shape in an RDF graph with a value for sh:targetNode in that is not an IRI or literal then is an ill-formed shape in . If is a shape in a shapes graph and has value t for sh:targetNode in then is a target from any data graph for in .

If is a shape in an RDF graph with a value for sh:targetClass in that is not an IRI then is an ill-formed shape in . If is a shape in a shapes graph and has value for sh:targetClass in then the set of ASHACL instances of in a data graph is a target from for in .

If is a shape in an RDF graph and is also an ASHACL instance of rdfs:Class in and is not an IRI then is an ill-formed shape in . If is a shape in a shapes graph and is also an ASHACL instance of rdfs:Class in then the set of ASHACL instances of in a data graph is a target from for in .

A shape in an RDF graph with a value for sh:targetSubjectsOf in that is not an IRI is an ill-formed shape in . If is a shape in a shapes graph and has value for sh:targetSubjectsOf in then the set of nodes in a data graph that are subjects of RDF triples in with predicate is a target from for in .

A shape in an RDF graph with a value for sh:targetObjectsOf in that is not an IRI is an ill-formed shape in . If is a shape in a shapes graph and has value for sh:targetObjectsOf in then the set of nodes in a data graph that are objects of RDF triples in with predicate is a target from for in .

The complete targets from a data graph for a shape in a shapes graph is the union of the targets from for in as defined above.

6.5 Value Nodes

A shape in an RDF graph with a value for sh:path in that is an ill-formed property path in is an ill-formed shape in . A shape in an RDF graph with more than one value for sh:path in is an ill-formed shape in .

Given an RDF term, a data graph, and a shape in a shapes graph the value nodes of with for in is the set containing the values of for in if has as value for sh:path in , or just if has no value for sh:path in .

7 Validation and Conformance Checking

Validation is the main relationship defined in ASHACL, usually producing a validation report containing the results of the validation. There are generally many different possible validation reports for a particular validation. Conformance checking is a simplified version of validation, usually producing a boolean result.

Validation and conformance checking can result in a failure. For example, a particular ASHACL processor might allow recursive shapes but result in a failure if it detects a loop. Failure can also result from resource exhaustion. Failures are reported through implementation-specific channels.

Validating a data graph against a shapes graph:

Given a data graph and a shapes graph, a results structure for the validation of against is a combination of some multiset where is the set of shapes in and is a results structure for the validation of against in . A validation report for the validation of against is a validation report for some results structure for the validation of against . A data graph conforms to a shapes graph if and only if there is a results structure for the validation of against that contains no top-level validation results.

Validating a data graph against a shape in a shapes graph:

Given a data graph and a shape in a shapes graph, a results structure for the validation of against in is a combination of some multiset where is the complete targets from for in and is a results structure for the validation of ti using against in . A data graph conforms to a shape in a shapes graph if and only if there is a results structure for the validation of against in that contains no top-level validation results.

Validating an RDF term using a data graph against a shape in a shapes graph:

Given an RDF term, a data graph, and a shape in a shapes graph a results structure for the validation of using against in is a combination of some multiset where is the constraints of in , is an element of , and is the value nodes of with for in , provided that does not have a value for sh:deactivated in that is a literal with datatype xsd:boolean and whose literal value is true. If does have such a value for sh:deactivated in then any results structure for the validation of f using against in has no top-level validation results. An RDF term f and a data graph conform to a shape in a shapes graph if and only if there is a results structure for the validation of using against in S that contains no top-level validation results.

Note: Although there can be multiple possible results structures for a particular validation, if any results structure for the validation has no top-level validation results they will all have no top-level validation results.

8 Constraint1 Components and Validation

This section defines the ASHACL constraint components along with their parameters and how they participate in validation.

Given an RDF term , a set of RDF terms , a data graph , a constraint , and a shape in a shapes graph the possible results of validating f and with against in , , is a set of results structures as defined in the rest of this section.

sh:ClassConstraintComponent

is a constraint component with mandatory parameter sh:class. A shape in an RDF graph with a value for sh:class in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:ClassConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not an ASHACL instance of in , and no other top-level validation results.

sh:DatatypeConstraintComponent

is a constraint component with mandatory parameter sh:datatype. A shape in an RDF graph with a value for sh:datatype in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:DatatypeConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not a literal with datatype , and no other top-level validation results.

sh:NodeKindConstraintComponent

is a constraint component with mandatory parameter sh:nodeKind. A shape in an RDF graph with a value for sh:nodeKind in that is not one of sh:BlankNode, sh:IRI, or sh:Literal is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:NodeKindConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not a blank node if is sh:BlankNode, not an IRI if is sh:IRI, or not a literal if is sh:Literal, and no other top-level validation results.

sh:MinCountConstraintComponent

is a constraint component with mandatory parameter sh:minCount. A shape in an RDF graph with a value for sh:minCount in that is not a literal with datatype xsd:integer is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MinCountConstraintComponent and that has mandatory parameter values contains a single top-level validation result from ,,,, and no other top-level validation results if the cardinality of is less than the literal value of , and no top-level validation results otherwise.

sh:MaxCountConstraintComponent

is a constraint component with mandatory parameter sh:maxCount. A shape in an RDF graph with a value for sh:maxCount in that is not a literal with datatype xsd:integer is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MaxCountConstraintComponent and that has mandatory parameter values contains a single top-level validation result from ,,,, and no other top-level validation results if the cardinality of is greater than the literal value of , and no top-level validation results otherwise.

sh:MinExclusiveConstraintComponent

is a constraint component with mandatory parameter sh:minExclusive. A shape in an RDF graph with a value for sh:minExclusive in that is not suitable for use in the SPARQL operator < is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MinExclusiveConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in for which returns false or produces an error in SPARQL, and no other top-level validation results.

sh:MinInclusiveConstraintComponent

is a constraint component with mandatory parameter sh:minInclusive. A shape in an RDF graph with a value for sh:minInclusive in that is not suitable for use in the SPARQL operator <= is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MinInclusiveConstraintComponent and that has mandatory parameter values contains different top-level validation result from ,,,,, for each in for which returns false or produces an error in SPARQL, and no other top-level validation results.

sh:MaxExclusiveConstraintComponent

is a constraint component with mandatory parameter sh:maxExclusive. A shape in an RDF graph with a value for sh:maxExclusive in that is not suitable for use in the SPARQL operator > is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MaxExclusiveConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in for which returns false or produces an error in SPARQL, and no other top-level validation results.

sh:MaxInclusiveConstraintComponent

is a constraint component with mandatory parameter sh:maxInclusive. A shape in an RDF graph with a value for sh:maxInclusive in that is not suitable for use in the SPARQL operator >= is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MaxInclusiveConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in for which returns false or produces an error in SPARQL, and no other top-level validation results.

sh:MinLengthConstraintComponent

is a constraint component with mandatory parameter sh:minLength. A shape in an RDF graph with a value for sh:minLength in that is not a literal with datatype xsd:integer is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MinLengthConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is a blank node or where the length of its string representation (as defined by the SPARQL str function) is less than the literal value of , and no other top-level validation results.

sh:MaxLengthConstraintComponent

is a constraint component with mandatory parameter sh:maxLength. A shape in an RDF graph with a value for sh:maxLength in that is not a literal with datatype xsd:integer is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:MaxLengthConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is a blank node or where the length of its string representation (as defined by the SPARQL str function) is greater than the literal value of , and no other top-level validation results.

sh:PatternConstraintComponent

is a constraint component with mandatory parameter sh:pattern and optional parameter sh:flags. A shape in an RDF graph with a value for sh:pattern or sh:flags in that is not a literal with datatype xsd:string is an ill-formed shape in . A shape in an RDF graph with more than one value for sh:pattern or sh:flags in is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:PatternConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is either a blank node or where the string representation (as defined by the SPARQL str function) does not match the given regular expression (as defined by the SPARQL REGEX function), and no other top-level validation results. If the constraint has optional parameter values then flags is used as the third argument of the SPARQL REGEX function, otherwise the third argument is the empty string.

sh:StemConstraintComponent

is a constraint component with mandatory parameter sh:stem A shape in an RDF graph with a value for sh:stem that is not a literal with datatype xsd:string is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:StemConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not an IRI or where its string representation (as defined by the SPARQL str function) does not start with (as defined by the SPARQL STRSTARTS function) the literal value of , and no other top-level validation results.

sh:LanguageInConstraintComponent

is a constraint component with mandatory list-taking parameter sh:languageIn. A shape in an RDF graph with a value for sh:languageIn in that is not an ASHACL list in whose members in are all literals with datatype xsd:string is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:LanguageInConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not a language-tagged string whose language tag matches the literal value of one of elements of as defined by the SPARQL langMatches function, and no other top-level validation results.

sh:UniqueLangConstraintComponent

is a constraint component with mandatory parameter sh:uniqueLang. A shape in an RDF graph with a value for sh:uniqueLang in that is not a literal with datatype xsd:boolean whose literal value is true is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:UniqueLangConstraintComponent and that has mandatory parameter values for a literal with literal value true contains a different top-level validation result from ,,,,, for each in that is is a language-tagged string with the same language tag as some other element of , and no other top-level validation results.

sh:EqualsConstraintComponent

is a constraint component with mandatory parameter sh:equals. A shape in an RDF graph with a value for sh:equals in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:EqualsConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is not a value of for in and for each a value of for in that is not in , and no other top-level validation results.

sh:DisjointConstraintComponent

is a constraint component with mandatory parameter sh:disjoint. A shape in an RDF graph with a value for sh:disjoint in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:DisjointConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that is also a value of for in , and no other top-level validation results.

sh:LessThanConstraintComponent

is a constraint component with mandatory parameter sh:lessThan. A shape in an RDF graph with a value for sh:lessThan in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:LessThanConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that does not compare as less than each value of for in using SPARQL operator <, and no other top-level validation results.

Note: A comparison that produces an error counts as not comparing as less than.

sh:LessThanOrEqualsConstraintComponent

is a constraint component with mandatory parameter sh:lessThanOrEquals. A shape in an RDF graph with a value for sh:lessThanOrEquals in that is not an IRI is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:LessThanOrEqualsConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in that does not compare as less than or equal each value of for in using SPARQL operator <=, and no other top-level validation results.

Note: A comparison that produces an error counts as not comparing as less than or equals.

sh:ShapeConstraintComponent

is a constraint component with mandatory shape-inducing parameter sh:shape. A shape in an RDF graph with a value for sh:shape in that is not an IRI or blank node is an ill-formed shape in .

Each results structure in where is not recursive and is a constraint that has kind sh:ShapeConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in where and do not conform to in , and no other top-level validation results.

sh:NotConstraintComponent

is a constraint component with mandatory shape-inducing parameter sh:not. A shape in an RDF graph with a value for sh:not in that is not an IRI or blank node is an ill-formed shape in .

Each results structure in where is not recursive and is a constraint that has kind sh:NotConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in where and do conform to in , and no other top-level validation results.

sh:AndConstraintComponent

is a constraint component with mandatory list-taking, shape-inducing parameter sh:and. A shape in an RDF graph with a value for sh:and in that is not an ASHACL list in whose members in are all IRIs or blank nodes in is an ill-formed shape in .

Each results structure in where is not recursive and is a constraint that has kind sh:AndConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in where and do not conform to each element of in , and no other top-level validation results.

sh:OrConstraintComponent

is a constraint component with mandatory list-taking, shape-inducing parameter sh:or. A shape in an RDF graph with a value for sh:or in that is not an ASHACL list in whose members in are all IRIs or blank nodes in is an ill-formed shape in .

Each results structure in where is not recursive and is a constraint that has kind sh:OrConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in where and do not conform to any element of in , and no other top-level validation results.

sh:QualifiedValueShapeConstraintComponent

is a constraint component with mandatory shape-inducing parameter sh:qualifiedValueShape and optional parameters sh:qualifiedMinCount and sh:qualifiedMaxCount A shape in an RDF graph with a value for sh:qualifiedValueShape in that is not an IRI or blank node is an ill-formed shape in . A shape in an RDF graph with a value for sh:qualifiedMinCount or sh:qualifiedMaxCount in that is not a literal with datatype xsd:integer is an ill-formed shape in . A shape in an RDF graph with more than one value for sh:qualifiedValueShape, sh:qualifiedMinCount, or sh:qualifiedMaxCount in is an ill-formed shape in . A shape in an RDF graph that has a value for sh:qualifiedValueShape in but no value for either sh:qualifiedMinCount or sh:qualifiedMaxCount in is an ill-formed shape in .

Each results structure in where is not recursive and is a constraint that has kind sh:QualifiedValueShapeConstraintComponent and that has mandatory parameter values contains a single top-level validation result from ,,,, and no other top-level validation results if the number of elements of where where and conform to in is less than the literal value of if is in the optional parameters of the constraint or is greater than the literal value is in the optional parameters of the constraint, and no top-level validation results otherwise.

sh:ClosedConstraintComponent

is a constraint component with mandatory parameter sh:closed and optional list-taking parameter sh:ignoredProperties A shape in an RDF graph with a value for sh:closed in that is not a literal with datatype xsd:boolean whose value is true is an ill-formed shape in . A shape in an RDF graph with a value for sh:ignoredProperties in that is not an ASHACL list in whose members in are all IRIs is an ill-formed shape in . A shape in an RDF graph with more than one value for sh:closed or sh:ignoredProperties in is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:ClosedConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each RDF triple in with subject whose predicate is not a value of some value of for sh:shape in for sh:path in and not a member of in if the constraint has optional parameter values , and no other top-level validation results.

sh:HasValueConstraintComponent

is a constraint component with mandatory parameter sh:hasValue.

Each results structure in where is a constraint that has kind sh:HasValueConstraintComponent and that has mandatory parameter values contains a single top-level validation result from ,,,, and no other top-level validation results if is not in , and no top-level validation results otherwise.

sh:InConstraintComponent

is a constraint component with mandatory list-taking parameter sh:in A shape in an RDF graph with a value for sh:in in that is not an ASHACL list in whose members in are all IRIs or blank nodes in is an ill-formed shape in .

Each results structure in where is a constraint that has kind sh:InConstraintComponent and that has mandatory parameter values contains a different top-level validation result from ,,,,, for each in where is not a member of in , and no other top-level validation results.

9 ASHACL Processors and Conformance

The keywords MAY, MUST, MUST NOT, and SHOULD are to be interpreted in this section as described in RFC2119 [1].

An ASHACL processor MUST provide an interface that takes two RDF graphs—a data graph and a potential shapes graph.

If the potential shapes graph is not a shapes graph the processor MUST report a failure. If the potential shapes graph is recursive the behaviour of the processor is not fully defined here; the processor MAY report a failure if the potential shapes graph is recursive or MAY extend this specification. The behavior of an ASHACL processor MUST satisfy all the requirements in this document regardless of whether the the potential shapes graph is recursive or not.

Unless the ASHACL processor reports a failure, it MUST either return a representation, or a location from which a representation can be retrieved, for an RDF graph that is a validation report for the validation of the data graph against the shapes graph. The representation can be a document in a syntax for RDF graphs, such as Turtle, or an RDF graph stored in a graph repository.

An ASHACL processor SHOULD provide a version of the above interface where the representation of the validation report is a file containing a Turtle document.

An ASHACL processor SHOULD provide an interface similar to the first interface above except that the return value of the interface is a boolean indicating whether the data graph conforms to the shapes graph.

An ASHACL processor SHOULD provide versions of the above interfaces where the potential shapes graph is formed by starting with an initial graph and merging in other graphs accessible at locations that are values of RDF triples with predicate owl:imports in the potential shapes graph being formed.

An ASHACL processor SHOULD provide versions of the above interfaces where the potential shapes graph is formed by accessing locations that are objects of RDF triples with predicate sh:shapesGraph in the data graph and merging the RDF graphs available at these locations into an initial graph or potential shapes graph.

An ASHACL processor SHOULD provide versions of the above interfaces where the data graph is the result of using owl:imports as above starting with some initial data graph or where the data graph is the result of performing inference according to the inferences required in one or more SPARQL entailment regimes [3] specified as the objects of RDF triples in the shapes graph with predicate sh:entailment starting with an initial data graph.

An ASHACL processor SHOULD provide two extra versions of each interface above that it provides. The first of these takes in addition an IRI and validates or checks conformance with respect to the data graph and the IRI as a shape in the shapes graph. The second of these takes in addition also an IRI or RDF literal and validates or checks conformance with respect to the IRI or RDF literal using the data graph and the IRI as a shape in the shapes graph.

If an ASHACL processor accesses any persistent representation of any graph that contributes to the data graph or the potential shapes graph the ASHACL processor MUST NOT change these representations. An ASHACL processor MAY create a persistent representation of a validation report that it constructs so long as the ASHACL processor does not not violate the previous requirement.

10 Conclusion

It is easier to fix SHACL Core, which has been done here, than it is to fix SHACL-SPARQL, which requires at least a suitable definition of pre-binding. A workable specification of SHACL-SPARQL is thus deferred to future work.

11 Changes from previous version

This version of the document extends the conditions for ill-formed property paths include blank nodes that have a value for rdf:rest and a value for one of the ASHACL properties that are used to encode SPARQL property path expressions. This version of the document limits the shapes in a shapes graph to those nodes in the graph that are SHACL instances of sh:Shape, have a value for any of the target predicates, or are used as shapes in these nodes.

References