Movatterモバイル変換


[0]ホーム

URL:


W3C

Shapes Constraint Language (SHACL)

W3C Recommendation

This version:
https://www.w3.org/TR/2017/REC-shacl-20170720/
Latest published version:
https://www.w3.org/TR/shacl/
Latest editor's draft:
https://w3c.github.io/data-shapes/shacl/
Implementation report:
https://w3c.github.io/data-shapes/data-shapes-test-suite/
Previous version:
https://www.w3.org/TR/2017/PR-shacl-20170608/
Editors:
Holger Knublauch,TopQuadrant, Inc.
Dimitris Kontokostas,University of Leipzig
Repository:
GitHub
Issues
Test Suite:
SHACL Test Suite

Please check theerrata for any errors or issues reported since publication.

See alsotranslations.

Copyright © 2017W3C® (MIT,ERCIM,Keio,Beihang).W3Cliability,trademark anddocument use rules apply.


Abstract

This document defines the SHACL Shapes Constraint Language, a language for validating RDF graphs against a set of conditions. These conditions are provided as shapes and other constructs expressed in the form of an RDF graph. RDF graphs that are used in this manner are called "shapes graphs" in SHACL and the RDF graphs that are validated against a shapes graph are called "data graphs". As SHACL shape graphs are used to validate that data graphs satisfy a set of conditions they can also be viewed as a description of the data graphs that do satisfy these conditions. Such descriptions may be used for a variety of purposes beside validation, including user interface building, code generation and data integration.

Status of This Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of currentW3C publications and the latest revision of this technical report can be found in theW3C technical reports index at https://www.w3.org/TR/.

This document was published by theRDF Data Shapes Working Group as a Recommendation. Comments regarding this document are welcome. Please send them topublic-rdf-shapes@w3.org (subscribe,archives).

Please see the Working Group'simplementation report.

This document has been reviewed byW3C Members, by software developers, and by otherW3C groups and interested parties, and is endorsed by the Director as aW3C Recommendation. It is a stable document and may be used as reference material or cited from another document.W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.

This document was produced by a group operating under the5 February 2004W3C Patent Policy.W3C maintains apublic list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes containsEssential Claim(s) must disclose the information in accordance withsection 6 of theW3C Patent Policy.

This document is governed by the1 March 2017W3C Process Document.

Document Outline

The introduction includes aTerminology section.

The sections 2 - 4 cover theSHACL Core language and may be read independently from the later sections.

The sections 5 and 6 are about the features thatSHACL-SPARQL has in addition to the Core language. These advanced features are SPARQL-based constraints and constraint components.

The syntax of SHACL is RDF. The examples in this document use Turtle [turtle] and (in one instance) JSON-LD [json-ld]. Other RDF serializations such as RDF/XML may be used in practice. The reader should be familiar with basic RDF concepts [rdf11-concepts] such as triples and, for the advanced concepts of SHACL, with SPARQL [sparql11-query].

1.Introduction

This document specifies SHACL (Shapes Constraint Language), a language for describing and validating RDF graphs. This section introduces SHACL with an overview of the key terminology and an example to illustrate basic concepts.

1.1Terminology

Throughout this document, the following terminology is used.

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

Definitions are complete within this document, i.e., if there is no rule to make some situation true in this document then the situation is false.

Basic RDF Terminology
This document uses the termsRDF graph,RDF triple,IRI,literal,blank node,node of an RDF graph,RDF term, andsubject,predicate, andobject of RDF triples, anddatatype as defined in RDF 1.1 Concepts and Abstract Syntax [rdf11-concepts].Language tags are defined as in [BCP47].
Property Value and Path
Aproperty is anIRI. AnRDF termn has avaluev for propertyp in anRDF graph if there is anRDF triple in the graph withsubjectn,predicatep, andobjectv. The phrase "Every value of P in graph G ..." means "Every object of a triple in G with predicate P ...". (In this document, the verbsspecify ordeclare are sometimes used to express the fact that an RDF term has values for a given predicate in a graph.)
SPARQL property paths are defined as inSPARQL 1.1. An RDF termn has valuev forSPARQL property path expressionp in an RDF graphG if there is a solution mapping in the result of the SPARQL querySELECT ?s ?o WHERE { ?s p' ?o } onG that binds?s ton and?o tov, wherep' is SPARQL surface syntax forp.
SHACL Lists
ASHACL list in an RDF graphG is anIRI or ablank nodethat is eitherrdf:nil(provided thatrdf:nil has novaluefor eitherrdf:first orrdf:rest), or has exactly onevaluefor the propertyrdf:first inG and exactly onevaluefor the propertyrdf:rest inG that is also a SHACL list inG,and the list does not have itself as a value of the property pathrdf:rest+ inG.
Themembers of any SHACL list exceptrdf:nil in an RDF graphG consist of its value forrdf:first inG followed by the members inG of its value forrdf:rest inG. The SHACL listrdf:nil has no members in any RDF graph.
Binding, Solution
Abinding is a pair (variable,RDF term), consistent with the term's use inSPARQL. Asolution is a set of bindings, informally often understood as one row in the body of the result table of a SPARQL query. Variables are not required to be bound in a solution.
SHACL Subclass, SHACL superclass
AnodeSub in anRDF graph is aSHACL subclass of anothernodeSuper in thegraph if there is a sequence oftriples in thegraph each with predicaterdfs:subClassOf such that thesubject of the firsttriple isSub, theobject of the last triple isSuper, and theobject of eachtriple except the last is thesubject of the next. IfSub is aSHACL subclass ofSuper in anRDF graph thenSuper is aSHACL superclass ofSub in thegraph.
SHACL Type
TheSHACL types of anRDF term in anRDF graph is the set of itsvalues forrdf:type in thegraph as well as theSHACL superclasses of thesevalues in thegraph.
SHACL Class
Nodes in anRDF graph that are subclasses, superclasses, or types ofnodes in thegraph are referred to asSHACL class.
SHACL Class Instance
Anoden in anRDF graphG is aSHACL instance of aSHACL classC inG if one of theSHACL types ofn inG isC.
SHACL Core and SHACL-SPARQL
The SHACL specification is divided into SHACL Core and SHACL-SPARQL.SHACL Core consists of frequently needed features for the representation of shapes, constraints and targets. All SHACL implementationsMUST at least implement SHACL Core.SHACL-SPARQL consists of all features of SHACL Core plus the advanced features of SPARQL-based constraints and an extension mechanism to declare new constraint components.

1.2Document Conventions

Within this document, the following namespace prefix bindings are used:

PrefixNamespace
rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs:http://www.w3.org/2000/01/rdf-schema#
sh:http://www.w3.org/ns/shacl#
xsd:http://www.w3.org/2001/XMLSchema#
ex:http://example.com/ns#

Note that the URI of the graph defining the SHACL vocabulary itself is equivalent to the namespace above, i.e. it includes the#. References to the SHACL vocabulary, e.g. viaowl:imports should include the#.

Throughout the document, color-coded boxes containing RDF graphs in Turtle will appear. These fragments of Turtle documents use the prefix bindings given above.

# This box represents an input shapes graph# Triples that can be omitted are marked as grey e.g.<s> <p> <o> .
# This box represents an input data graph.# When highlighting is used in the examples:# Elements highlighted in blue arefocus nodesex:Bob a ex:Person .# Elements highlighted in red are focus nodes that failvalidationex:Alice a ex:Person .
# This box represents an output results graph

SHACL Definitions appear in blue boxes:

SPARQL or TEXTUAL DEFINITIONS
# This box contains SPARQL or textual definitions.

Grey boxes such as this include syntax rules that apply to theshapes graph.

true denotes the RDF term"true"^^xsd:boolean.false denotes the RDF term"false"^^xsd:boolean.

1.3Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

The key wordsMAY,MUST,MUST NOT, andSHOULD are to be interpreted as described in [RFC2119].

This document defines theSHACL Core language, also referred to as justSHACL, as described in Part A, and theSHACL-SPARQL language that extends SHACL Core with constructs described in Part B. This specification describes conformance criteria for:

This document includes syntactic rules that shapes and other nodes need to fulfill in theshapes graph. These rules are typically of the formA shape must have... orThe values of X are literals orAll objects of triples with predicate P must be IRIs. The complete list of these rules can be found in theappendix. Nodes that violate any of these rules are calledill-formed. Nodes that violate none of these rules are calledwell-formed. Ashapes graph is ill-formed if it contains at least one ill-formed node.

The remainder of this section is informative.

SHACL Core processors that do not also support SHACL-SPARQL ignore any SHACL-SPARQL constructs such assh:sparqltriples.

1.4SHACL Example

This section is non-normative.

The following exampledata graph contains threeSHACL instances of theclassex:Person.

ex:Alicea ex:Person ;ex:ssn "987-65-432A" .  ex:Boba ex:Person ;ex:ssn "123-45-6789" ;ex:ssn "124-35-6789" .  ex:Calvina ex:Person ;ex:birthDate "1971-07-07"^^xsd:date ;ex:worksFor ex:UntypedCompany .

The following conditions are shown in the example:

The aforementioned conditions can be represented asshapes andconstraints in the followingshapes graph:

ex:PersonShapea sh:NodeShape ;sh:targetClass ex:Person ;    # Applies to all personssh:property [                 # _:b1sh:path ex:ssn ;           # constrains the values of ex:ssnsh:maxCount 1 ;sh:datatype xsd:string ;sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;] ;sh:property [                 # _:b2sh:path ex:worksFor ;sh:class ex:Company ;sh:nodeKind sh:IRI ;] ;sh:closed true ;sh:ignoredProperties ( rdf:type ) .

The example below shows the same shape definition as a possible JSON-LD [json-ld] fragment. Note that we have left out a@context declaration, and depending on the@context the rendering may look quite different. Therefore this example should be understood as an illustration only.

{"@id" : "ex:PersonShape","@type" : "NodeShape","targetClass" : "ex:Person","property" : [{"path" : "ex:ssn","maxCount" : 1,"datatype" : "xsd:string" ,"pattern" : "^\\d{3}-\\d{2}-\\d{4}$"},{"path" : "ex:worksFor","class" : "ex:Company","nodeKind" : "sh:IRI"}],"closed" : true,"ignoredProperties" : [ "rdf:type" ]}

We can use the shape declaration above to illustrate some of the key terminology used by SHACL. Thetarget for theshapeex:PersonShape is the set of allSHACL instances of theclassex:Person. This is specified using the propertysh:targetClass. During the validation, these target nodes becomefocus nodes for the shape. Theshapeex:PersonShape is anode shape, which means that it applies to the focus nodes. It declaresconstraints on thefocus nodes, for example using theparameterssh:closed andsh:ignoredProperties. Thenode shape also declares two other constraints with the propertysh:property, and each of these is backed by aproperty shape. Theseproperty shapes declare additionalconstraints usingparameters such assh:datatype andsh:maxCount.

Some of theproperty shapes specify parameters from multipleconstraint components in order to restrict multiple aspects of theproperty values. For example, in theproperty shape forex:ssn, parameters from threeconstraint components are used. Theparameters of theseconstraint components aresh:datatype,sh:pattern andsh:maxCount. For eachfocus node theproperty values ofex:ssn will be validated against all three components.

SHACLvalidation based on the provideddata graph andshapes graph would produce the followingvalidation report. See the sectionValidation Report for details on the format.

[a sh:ValidationReport ;sh:conforms false ;sh:result[a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Alice ;sh:resultPath ex:ssn ;sh:value "987-65-432A" ;sh:sourceConstraintComponent sh:RegexConstraintComponent ;sh:sourceShape ... blank node _:b1 on ex:ssn above ... ;] ,[a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Bob ;sh:resultPath ex:ssn ;sh:sourceConstraintComponent sh:MaxCountConstraintComponent ;sh:sourceShape ... blank node _:b1 on ex:ssn above ... ;] ,[a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Calvin ;sh:resultPath ex:worksFor ;sh:value ex:UntypedCompany ;sh:sourceConstraintComponent sh:ClassConstraintComponent ;sh:sourceShape ... blank node _:b2 on ex:worksFor above ... ;] ,[a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Calvin ;sh:resultPath ex:birthDate ;sh:value "1971-07-07"^^xsd:date ;sh:sourceConstraintComponent sh:ClosedConstraintComponent ;sh:sourceShape sh:PersonShape ;] ] .

Thevalidation results are enclosed in avalidation report. The firstvalidation result is produced becauseex:Alice has avalue forex:ssn that does not match the regular expression specified by the propertysh:regex. The secondvalidation result is produced becauseex:Bob has more than the permitted number ofvalues for the propertyex:ssn as specified by thesh:maxCount of 1. The thirdvalidation result is produced becauseex:Calvin has avalue forex:worksFor that does not have anrdf:type triple that makes it aSHACL instance ofex:Company. The forthvalidation result is produced because theshapeex:PersonShape has the propertysh:closed set totrue butex:Calvin uses the propertyex:birthDate which is neither one of the predicates from any of theproperty shapes of the shape, nor one of the properties listed usingsh:ignoredProperties.

1.5Relationship between SHACL and RDFS inferencing

SHACL uses the RDF and RDFS vocabularies, but full RDFS inferencing is not required.

However, SHACL processorsMAY operate on RDF graphs that include entailments [sparql11-entailment] - either pre-computed before being submitted to a SHACL processor or performed on the fly as part of SHACL processing (without modifying eitherdata graph orshapes graph). To support processing of entailments, SHACL includes the propertysh:entailment to indicate what inferencing is required by a givenshapes graph.

Thevalues of the propertysh:entailment are IRIs. Common values for this property are covered by [sparql11-entailment].

SHACL implementationsMAY, but are not required to, support entailment regimes. If ashapes graph contains anytriple with thepredicatesh:entailment andobjectE and the SHACL processor does not supportE as an entailment regime for the givendata graph then the processorMUST signal afailure. Otherwise, the SHACL processorMUST provide the entailments for all of the values ofsh:entailment in theshapes graph, and any inferred triplesMUST be returned by all queries against thedata graph during thevalidation process.

1.6Relationship between SHACL and SPARQL

This section is non-normative.

ForSHACL Core this specification uses parts of SPARQL 1.1 in non-normative alternative definitions of the semantics ofconstraint components andtargets. While these may help some implementers, SPARQL is not required for the implementation of the SHACL Core language.

SHACL-SPARQL is based on SPARQL 1.1 and uses it as a mechanism to declare constraints and constraint components. Implementations that cover only the SHACL Core features are not required to implement these mechanisms.

SPARQL variables using the$ marker represent externalbindings that arepre-bound or, in the case of$PATH,substituted in the SPARQL query before execution (as explained in6.3Validation with SPARQL-based Constraint Components).

The definition of someconstraints requires or is simplified through access to theshapes graph during query execution. SHACL-SPARQL processorsMAYpre-bind the variableshapesGraph to provide access to theshapes graph. Access to theshapes graph is not a requirement for supporting the SHACL Core language. The variableshapesGraph can also be used inSPARQL-based constraints andSPARQL-based constraint components. However, suchconstraints may not be interoperable across different SHACL-SPARQL processors or not applicable to remote RDF datasets.

Note that at the time of writing, SPARQL EXISTS has been imperfectly defined and implementations vary. While aW3C Community Group is working on improving this situation, users of SPARQL are advised that the use of EXISTS may have inconsistent results and should be approached with care.

The button below can be used to show or hide the SPARQL definitions.

Part 1: SHACL Core

2.Shapes and Constraints

The following introduction is non-normative.

The following informal diagram provides an overview of some of the key classes in the SHACL vocabulary. Each box represents a class. The content of the boxes under the class name lists some of the properties that instances of these classes may have, together with their value types. The arrows indicaterdfs:subClassOf triples.

sh:Shape
sh:targetClass : rdfs:Class
sh:targetNode : any IRI or literal
sh:targetObjectsOf : rdf:Property
sh:targetSubjectsOf : rdf:Property
sh:deactivated : xsd:boolean
sh:message : xsd:string or rdf:langString
sh:severity : sh:Severity
Class Diagram Arrows
sh:NodeShape
Constraint parameters, for example:
sh:closed : xsd:boolean
sh:or : rdf:List
sh:not : sh:Shape
sh:property : sh:PropertyShape
sh:PropertyShape
Constraint parameters, for example:
sh:minCount,sh:maxCount : xsd:integer
sh:class orsh:datatype : rdfs:Resource
sh:node : sh:NodeShape
sh:name : xsd:string or rdf:langString
sh:description : xsd:string or rdf:langString
sh:group : sh:PropertyGroup
sh:path : rdfs:Resource

TheTurtle serialization of the SHACL vocabulary contains the complete SHACL vocabulary.

2.1Shapes

Ashape is anIRI orblank nodes that fulfills at least one of the following conditions in theshapes graph:

Note that the definition above does not include all of the syntax rules ofwell-formed shapes. Those are found throughout the document and summarized in AppendixB.Summary of SHACL Syntax Rules. For example, shapes that haveliterals as values forsh:targetClass areill-formed.

Informally, a shape determines how to validate afocus node based on thevalues of properties and other characteristics of the focus node. For example, shapes can declare the condition that a focus node be an IRI or that a focus node has a particular value for a property and also a minimum number of values for the property.

The SHACL Core language defines two types of shapes:

sh:Shape is theSHACL superclass of those two shape types in the SHACL vocabulary. Its subclassessh:NodeShape andsh:PropertyShape can be used as SHACL type of node and property shapes, respectively.

2.1.1Constraints, Parameters and Constraint Components

Shapes can declareconstraints using theparameters ofconstraint components.

Aconstraint component is anIRI. Each constraint component has one or moremandatory parameters, each of which is a property. Each constraint component has zero or moreoptional parameters, each of which is a property. Theparameters of a constraint component are its mandatory parameters plus its optional parameters.

For example, thecomponentsh:MinCountConstraintComponent declares theparametersh:minCount to represent the restriction that anode has at least a minimum number ofvalues for a particular property.

For aconstraint componentC withmandatory parametersp1, ...pn, ashapes in ashapes graphSGdeclares aconstraint that haskindC withmandatory parametervalues<p1,v1>, ...<pn,vn> inSG whens hasvi as avalue forpi inSG. For constraint components withoptional parameters, the constraint declaration consists of thevalues that the shape has for all mandatory and optional parameters of that component.

Some constraint components declare only a single parameter. For examplesh:ClassConstraintComponent has the single parametersh:class. These parameters may be used multiple times in the same shape, and eachvalue of such a parameter declares an individualconstraint. The interpretation of such declarations is conjunction, i.e. all constraints apply. The following example specifies that the values ofex:customer have to beSHACL instances of bothex:Customer andex:Person.

ex:InvoiceShapea sh:NodeShape ;sh:property [sh:path ex:customer ;sh:class ex:Customer ;sh:class ex:Person ;] .

Some constraint components such assh:PatternConstraintComponent declare more than one parameter. Shapes that have more than one value for any of the parameters of such components areill-formed.

One way to bypass this syntax rule is to spread the constraints across multiple (property) shapes, as illustrated in the following example.

ex:MultiplePatternsShapea sh:NodeShape ;sh:property [sh:path ex:name ;sh:pattern "^Start" ;sh:flags "i" ;] ;sh:property [sh:path ex:name ;sh:pattern "End$" ;] .

Constraint components are associated withvalidators, which provide instructions (for example expressed via SPARQL queries) on how the parameters are used to validate data. Validating anRDF term against ashape involves validating the term against eachconstraint where the shape hasvalues for allmandatory parameters of thecomponent of theconstraint, using the validators associated with the respective component.

The list of constraint components included in SHACL Core is described insection 4. SHACL-SPARQL can be used to declare additionalconstraint components based on SPARQL.

2.1.2Focus Nodes

AnRDF term that isvalidated against ashape using the triples from adata graph is called afocus node.

The remainder of this section is informative.

The set offocus nodes for ashape may be identified as follows:

2.1.3Targets

Target declarations of ashape in ashapes graph aretriples with theshape as thesubject and certain properties described in this document (e.g.,sh:targetClass) aspredicates. Target declarations can be used to producefocus nodes for ashape. Thetarget of atarget declaration is the set of RDF terms produced by applying the rules described in the remainder of this section to thedata graph. Thetarget of a shape is the union of all RDF terms produced by the individualtargets that are declared by theshape in theshapes graph.

SHACL Core includes the following kinds of targets:node targets,class-based targets (includingimplicit class-based targets),subjects-of targets, andobjects-of targets.

The remainder of this introduction is informative.

RDF terms produced by targets are not required to exist as nodes in thedata graph. Targets of a shape are ignored whenever a focus node is provided directly as input to the validation process for that shape. This includes the cases where the shape is a value of one of theshape-expecting constraint parameters (such assh:node) and a focus node is determined during the validation of the corresponding constraint component (such assh:NodeConstraintComponent). In such cases, the provided focus node does not need to be in thetarget of the shape.

2.1.3.1Node targets (sh:targetNode)

Anode target is specified using thesh:targetNode predicate.Eachvalue ofsh:targetNode in a shape is either anIRI or aliteral.

TEXTUAL DEFINITION
Ifs is ashape in ashapes graphSG ands hasvaluet forsh:targetNode inSG then{ t } is atarget from any data graph fors inSG.

The remainder of this section is informative.

With the example data below, onlyex:Alice is the target of the provided shape:

ex:PersonShapea sh:NodeShape ;sh:targetNode ex:Alice .
ex:Alice a ex:Person .ex:Bob a ex:Person .

The following query expresses a potential definition of node targets in SPARQL. The variabletargetNode will bepre-bound to the given value ofsh:targetNode. Allbindings of the variablethis from thesolution become focus nodes.

POTENTIAL DEFINITION IN SPARQL
SELECT DISTINCT ?this# ?this is the focus nodeWHERE {BIND ($targetNode AS ?this)# $targetNode ispre-bound to ex:Alice}
2.1.3.2Class-based Targets (sh:targetClass)

Aclass target is specified with thesh:targetClass predicate.Each value ofsh:targetClass in a shape is anIRI.

TEXTUAL DEFINITION
Ifs is a shape in a shapes graphSG ands hasvaluec forsh:targetClass inSG then the set ofSHACL instances ofc in a data graphDG is atarget fromDG fors inSG.

The remainder of this section is informative.

ex:PersonShapea sh:NodeShape ;sh:targetClass ex:Person .
ex:Alice a ex:Person .ex:Bob a ex:Person .ex:NewYork a ex:Place .

In this example, onlyex:Alice andex:Bob are focus nodes. Note that, according to theSHACL instance definition, all therdfs:subClassOf declarations needed to walk the class hierarchy need to exist in thedata graph. However, theex:Person a rdfs:Class triple is not required to exist in either graphs.

In the following example, the selected focus node is onlyex:Who.

ex:Doctor rdfs:subClassOf ex:Person .ex:Who a ex:Doctor .ex:House a ex:Nephrologist .

The following query expresses a potential definition of class targets in SPARQL. The variabletargetClass will bepre-bound to the given value ofsh:targetClass. Allbindings of the variablethis from thesolutions become focus nodes.

POTENTIAL DEFINITION IN SPARQL
SELECT DISTINCT ?this# ?this is the focus nodeWHERE {?this rdf:type/rdfs:subClassOf* $targetClass .# $targetClass ispre-bound to ex:Person}
2.1.3.3Implicit Class Targets

Informally, if ashape is also declared to be aclass in theshapes graph then allSHACL instances of this class are a target for the shape.

Ifs is aSHACL instance ofsh:NodeShape orsh:PropertyShape in an RDF graphG ands is also aSHACL instance ofrdfs:Class inG ands is not anIRI thens is anill-formed shape inG.

TEXTUAL DEFINITION
Ifs is aSHACL instance ofsh:NodeShape orsh:PropertyShape in ashapes graphSG ands is also aSHACL instance ofrdfs:Class inSG then the set ofSHACL instances ofs in a data graphDG is atarget fromDG fors inSG.

The remainder of this section is informative.

In the following example,ex:Alice is a focus node, because it is aSHACL instance ofex:Person which is both a class and a shape in theshapes graph.

ex:Persona rdfs:Class, sh:NodeShape .
ex:Alice a ex:Person .ex:NewYork a ex:Place .
2.1.3.4Subjects-of targets (sh:targetSubjectsOf)

Asubjects-of target is specified with the predicatesh:targetSubjectsOf.Thevalues ofsh:targetSubjectsOf in a shape areIRIs.

TEXTUAL DEFINITION
Ifs is a shape in a shapes graphSG ands hasvaluep forsh:targetSubjectsOf inSG then the set of nodes in a data graphDG that aresubjects of triples inDG withpredicatep is atarget fromDG fors inSG.

The remainder of this section is informative.

ex:TargetSubjectsOfExampleShapea sh:NodeShape ;sh:targetSubjectsOf ex:knows .
ex:Alice ex:knows ex:Bob .ex:Bob ex:livesIn ex:NewYork .

In the example above, onlyex:Alice is validated against the given shape, because it is thesubject of atriple that hasex:knows as itspredicate.

The following query expresses a potential definition of subjects-of targets in SPARQL. The variabletargetSubjectsOf will bepre-bound to the given value ofsh:targetSubjectsOf. Allbindings of the variablethis from thesolutions become focus nodes.

POTENTIAL DEFINITION IN SPARQL
SELECT DISTINCT ?this# ?this is the focus nodeWHERE {?this $targetSubjectsOf ?any .# $targetSubjectsOf ispre-bound to ex:knows}
2.1.3.5Objects-of targets (sh:targetObjectsOf)

Anobjects-of target is specified with the predicatesh:targetObjectsOf.Thevalues ofsh:targetObjectsOf in a shape areIRIs.

TEXTUAL DEFINITION
Ifs is a shape in a shapes graphSG ands hasvaluep forsh:targetObjectsOf inSG then the set of nodes in a data graphDG that areobjects of triples inDG withpredicatep is atarget fromDG fors inSG.

The remainder of this section is informative.

ex:TargetObjectsOfExampleShapea sh:NodeShape ;sh:targetObjectsOf ex:knows .
ex:Alice ex:knowsex:Bob .ex:Bob ex:livesIn ex:NewYork .

In the example above, onlyex:Bob is validated against the given shape, because it is theobject of atriple that hasex:knows as itspredicate.

The following query expresses a potential definition of objects-of targets in SPARQL. The variabletargetObjectsOf will bepre-bound to the given value ofsh:targetObjectsOf. Allbindings of the variablethis from thesolutions become focus nodes.

POTENTIAL DEFINITION IN SPARQL
SELECT DISTINCT ?this# ?this is the focus nodeWHERE {?any $targetObjectsOf ?this .# $targetObjectsOf ispre-bound to ex:knows}

2.1.4Declaring the Severity of a Shape

Shapes can specify onevalue for the propertysh:severity in theshapes graph.Each value ofsh:severity in a shape is anIRI.

The values ofsh:severity are calledseverities. SHACL includes the three IRIs listed in the table below to representseverities. These are declared in the SHACL vocabulary as SHACL instances ofsh:Severity.

SeverityDescription
sh:InfoA non-critical constraint violation indicating an informative message.
sh:WarningA non-critical constraint violation indicating a warning.
sh:ViolationA constraint violation.

The remainder of this section is informative.

The specific values ofsh:severity have no impact on the validation, butMAY be used by user interface tools to categorize validation results. The values ofsh:severity are used by SHACL processors to populate thesh:resultSeverity field of validation results, seesection on severity in validation results. Any IRI can be used as a severity.

For every shape,sh:Violation is the default ifsh:severity is unspecified. The following example illustrates this.

ex:MyShapea sh:NodeShape ;sh:targetNode ex:MyInstance ;sh:property [    # _:b1# Violations of sh:minCount and sh:datatype are produced as warningssh:path ex:myProperty ;sh:minCount 1 ;sh:datatype xsd:string ;sh:severity sh:Warning ;] ;sh:property [    # _:b2# The default severity here is sh:Violationsh:path ex:myProperty ;sh:maxLength 10 ;sh:message "Too many characters"@en ;sh:message "Zu viele Zeichen"@de ;] .
ex:MyInstanceex:myProperty "http://toomanycharacters"^^xsd:anyURI .
[a sh:ValidationReport ;sh:conforms false ;sh:result[a sh:ValidationResult ;sh:resultSeverity sh:Warning ;sh:focusNode ex:MyInstance ;sh:resultPath ex:myProperty ;sh:value "http://toomanycharacters"^^xsd:anyURI ;sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;sh:sourceShape _:b1 ;] ,[a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:MyInstance ;sh:resultPath ex:myProperty ;sh:value "http://toomanycharacters"^^xsd:anyURI ;sh:resultMessage "Too many characters"@en ;sh:resultMessage "Zu viele Zeichen"@de ;sh:sourceConstraintComponent sh:MaxLengthConstraintComponent ;sh:sourceShape _:b2 ;]] .

2.1.5Declaring Messages for a Shape

Shapes can have values for the propertysh:message.The values ofsh:message in a shape are eitherxsd:string literals or literals with a language tag. A shape should not have more than one value forsh:message with the same language tag.

If a shape has at least one value forsh:message in the shapes graph, then allvalidation results produced as a result of the shape will have exactly these messages as their value ofsh:resultMessage, i.e. the values will be copied from the shapes graph into the results graph. (Note that in SHACL-SPARQL,SPARQL-based constraints andSPARQL-based constraint components provide additional means to declare such messages.)

The remainder of this section is informative.

The example from the previous section uses this mechanism to supply the second validation result with two messages. See thesection onsh:resultMessage in the validation results on further details on how the values ofsh:resultMessage are populated.

2.1.6Deactivating a Shape

Shapes can have at most one value for the propertysh:deactivated.The value ofsh:deactivated in a shape must be eithertrue orfalse.

A shape that has thevaluetrue for the propertysh:deactivated is calleddeactivated. All RDF termsconform to a deactivated shape.

The remainder of this section is informative.

Use cases of this feature include shape reuse and debugging. In scenarios where shapes from other graphs or files are imported into a givenshapes graph,sh:deactivated can be set totrue in the local shapes graph for imported shapes to exclude shapes that do not apply in the current application context. This makes it possible to reuse SHACL graphs developed by others even if you disagree with certain assumptions made by the original authors. If a shape author anticipates that a shape may need to be disabled or modified by others, it is a good practice to useIRIs instead ofblank nodes for the actual shapes. For example, aproperty shape for the propertyex:name at the shapeex:PersonShape may have the IRIex:PersonShape-name. Another typical use case ofsh:deactivated is during the development and testing of shapes, to (temporarily) disable certain shapes.

The following example illustrates the use ofsh:deactivated to deactivate a shape. In cases where shapes are imported from other graphs, thesh:deactivated true triple would be in the importing graph.

ex:PersonShapea sh:NodeShape ;sh:targetClass ex:Person ;sh:property ex:PersonShape-name .ex:PersonShape-namea sh:PropertyShape ;sh:path ex:name ;sh:minCount 1 ;sh:deactivated true .

With the following data, no constraint violation will be reported even though the instance does not have any value forex:name.

ex:JohnDoe a ex:Person .

2.2Node Shapes

Anode shape is ashape in theshapes graph that is not thesubject of atriple withsh:path as itspredicate. It is recommended, but not required, for anode shape to be declared as aSHACL instance ofsh:NodeShape.SHACL instances ofsh:NodeShape cannot have avalue for the propertysh:path.

Informally, node shapes specify constraints that need to be met with respect tofocus nodes. In contrast toproperty shapes they primarily apply to the focus node itself, not to its property values.

2.3Property Shapes

Aproperty shape is ashape in theshapes graphthat is thesubject of atriple that hassh:path as itspredicate.A shape has at most onevalue forsh:path.Eachvalue ofsh:path in a shape must be awell-formedSHACL property path. It is recommended, but not required, for aproperty shape to be declared as aSHACL instance ofsh:PropertyShape.SHACL instances ofsh:PropertyShape have onevalue for the propertysh:path.

Informally, property shapes specify constraints that need to be met with respect tonodes that can be reached from thefocus node either by directly following a given property (specified as anIRI) or any otherSHACL property path, specified usingsh:path.

Note that the definitions ofwell-formedproperty shapes andnode shapes make these two sets of nodes disjoint.

The following example illustrates some syntax variations of property shapes.

ex:ExampleNodeShapeWithPropertyShapesa sh:NodeShape ;sh:property [sh:path ex:email ;sh:name "e-mail" ;sh:description "We need at least one email value" ;sh:minCount 1 ;] ;sh:property [sh:path (ex:knows ex:email) ;sh:name "Friend's e-mail" ;sh:description "We need at least one email for everyone you know" ;sh:minCount 1 ;] .ex:ExamplePropertyShapea sh:PropertyShape ;sh:path ex:email ;sh:description "We need at least one email value" ;sh:minCount 1 .

2.3.1SHACL Property Paths

SHACL includes RDF terms to represent the following subset ofSPARQL property paths:PredicatePath,InversePath,SequencePath,AlternativePath,ZeroOrMorePath,OneOrMorePath andZeroOrOnePath.

The following sub-sections provide syntax rules ofwell-formedSHACL property paths together with mapping rules toSPARQL 1.1 property paths. These rules define thepath mappingpath(p,G) in an RDF graphG of an RDF termp that is a SHACL property path inG. Two SHACL property paths are consideredequivalent paths when they map to the exact same SPARQL property paths.

A node in an RDF graph is awell-formedSHACL property pathp if it satisfies exactly one of the syntax rules in the following sub-sections.A nodep is not awell-formed SHACL property path ifp is a blank node and any path mappings ofp directly or transitively referencep.

The following example illustrates some valid SHACL property paths, together with their SPARQL 1.1 equivalents.

SPARQL Property path: ex:parentSHACL Property path: ex:parentSPARQL Property path: ^ex:parentSHACL Property path: [ sh:inversePath ex:parent ]SPARQL Property path: ex:parent/ex:firstNameSHACL Property path: ( ex:parent ex:firstName )SPARQL Property path: rdf:type/rdfs:subClassOf*SHACL Property path: ( rdf:type [ sh:zeroOrMorePath rdfs:subClassOf ] )SPARQL Property path: ex:father|ex:motherSHACL Property path: [ sh:alternativePath ( ex:father ex:mother  ) ]
2.3.1.1Predicate Paths

Apredicate path is anIRI.

Ifp is apredicate path thenpath(p,G) is a SPARQLPredicatePath withp asiri.

2.3.1.2Sequence Paths

Asequence path is ablank node that is aSHACL list with at least twomembers and each member is awell-formed SHACL property path.

Ifp is asequence path inG with listmembersv1,v2, ...,vn thenpath(p,G) is a SPARQLSequencePath ofpath(v1,G) aselt1, and the results of thepath mapping of the list node ofv2 aselt2.

Informal note: thenodes in such aSHACL list should not havevalues for other properties besiderdf:first andrdf:rest.

2.3.1.3Alternative Paths

Analternative path is ablank node that is the subject of exactly one triple inG. This triple hassh:alternativePath as predicate,L as object, andL is aSHACL list with at least twomembers and each member ofL is awell-formed SHACL property path.

Ifp is analternative path inG then, for the members of its SHACL listL:v1,v2, ...,vn,path(p,G) is a SPARQLAlternativePath withpath(v1,G) aselt1 followed by anAlternativePath forv2 aselt2, ..., up topath(vn,G).

2.3.1.4Inverse Paths

Aninverse path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:inversePath as predicate, and theobjectv is awell-formed SHACL property path.

Ifp is aninverse path inG thenpath(p,G) is a SPARQLInversePath withpath(v,G) as itselt.

2.3.1.5Zero-Or-More Paths

Azero-or-more path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:zeroOrMorePath aspredicate, and theobjectv is awell-formed SHACL property path.

Ifp is azero-or-more path inG thenpath(p,G) is a SPARQLZeroOrMorePath withpath(v,G) as itselt.

2.3.1.6One-Or-More Paths

Aone-or-more path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:oneOrMorePath aspredicate, and theobjectv is awell-formed SHACL property path.

Ifp is aone-or-more path inG thenpath(p,G) is a SPARQLOneOrMorePath withpath(v,G) as itselt.

2.3.1.7Zero-Or-One Paths

Azero-or-one path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:zeroOrOnePath aspredicate, and theobjectv is awell-formed SHACL property path.

Ifp is azero-or-one path inG thenpath(p,G) is a SPARQLZeroOrOnePath withpath(v,G) as itselt.

2.3.2Non-Validating Property Shape Characteristics

This section is non-normative.

While the previous sections introduced properties that represent validation conditions, this section covers properties that are ignored by SHACL processors. The use of these so-callednon-validating properties is entirely optional and not subject to formal interpretation contracts. TheyMAY be used for purposes such as form building or predictable printing of RDF files.

2.3.2.1sh:name and sh:description

Property shapes may have one or morevalues forsh:name to provide human-readable labels for the property in the target where it appears. If present, toolsSHOULD prefer those locally specified labels over globally specified labels at therdf:Property itself. For example, if a form displays a node that is in the target of a given property shape with ansh:name, then the toolSHOULD use the provided name. Similarly, property shape may have values forsh:description to provide descriptions of the property in the given context. Bothsh:name andsh:description may have multiplevalues, but should only have onevalue per language tag.

2.3.2.2sh:order

Property shapes may have onevalue for the propertysh:order to indicate the relative order of the property shape for purposes such as form building. The values ofsh:order are decimals.sh:order is not used for validation purposes and may be used with any type of subjects. If present at property shapes, the recommended use ofsh:order is to sort the property shapes in an ascending order, for example so that properties with smaller order are placed above (or to the left) of properties with larger order.

2.3.2.3sh:group

Property shapes may link to anSHACL instance of the classsh:PropertyGroup using the propertysh:group to indicate that the shape belongs to a group of related property shapes. Each group may have additional triples that serve application purposes, such as anrdfs:label for form building. Groups may also have ansh:order property to indicate the relative ordering of groups within the same form.

2.3.2.4sh:defaultValue

Property shapes may have a single value forsh:defaultValue. The default value does not have fixed semantics in SHACL, butMAY be used by user interface tools to pre-populate input widgets. The value type of thesh:defaultValue should align with the specifiedsh:datatype orsh:class of the same shape.

The following example illustrates the use of these various features together.

ex:PersonFormShapea sh:NodeShape ;sh:property [sh:path ex:firstName ;sh:name "first name" ;sh:description "The person's given name(s)" ;sh:order 0 ;sh:group ex:NameGroup ;] ;sh:property [sh:path ex:lastName ;sh:name "last name" ;sh:description "The person's last name" ;sh:order 1 ;sh:group ex:NameGroup ;] ;sh:property [sh:path ex:streetAddress ;sh:name "street address" ;sh:description "The street address including number" ;sh:order 11 ;sh:group ex:AddressGroup ;] ;sh:property [sh:path ex:locality ;sh:name "locality" ;sh:description "The suburb, city or town of the address" ;sh:order 12 ;sh:group ex:AddressGroup ;] ;sh:property [sh:path ex:postalCode ;sh:name "postal code" ;sh:name "zip code"@en-US ;sh:description "The postal code of the locality" ;sh:order 13 ;sh:group ex:AddressGroup ;] .ex:NameGroupa sh:PropertyGroup ;sh:order 0 ;rdfs:label "Name" .ex:AddressGroupa sh:PropertyGroup ;sh:order 1 ;rdfs:label "Address" .

A form building applicationMAY use the information above to display information as follows:

Name
first name:John
last name:Doe
Address
street address:123 Silverado Ave
locality:Cupertino
zip code:54321

3.Validation and Graphs

Validation takes adata graph and ashapes graph as input and produces avalidation report containing the results of the validation.Conformance checking is a simplified version of validation, producing a boolean result. A system that is capable of performing validation is called aprocessor, and the verbprocessing is sometimes used to refer to the validation process.

SHACL defines an RDFValidation Report Vocabulary that can be used by processors that produce validation reports as RDF results graphs. This specification uses the SHACL results vocabulary for the normative definitions of thevalidators associated with theconstraint components. Only SHACL implementations that can produce all of the mandatory properties of theValidation Report Vocabulary are standards-compliant.

3.1Shapes Graph

Ashapes graph is an RDF graph containing zero or more shapes that is passed into a SHACLvalidation process so that adata graph can be validated against the shapes.

The remainder of this section is informative.

Shapes graphs can be reusable validation modules that can be cross-referenced with the predicateowl:imports. As a pre-validation step, SHACL processorsSHOULD extend the originally providedshapes graph by transitively following and importing all referencedshapes graphs through theowl:imports predicate. The resulting graph forms the inputshapes graph for validation andMUST NOT be further modified during the validation process.

In addition to shape declarations, the shapes graph may contain additional information for the SHACL processor such assh:entailment statements.

3.2Data Graph

Any RDF graph can be adata graph.

The remainder of this section is informative.

A data graph is one of the inputs to the SHACL processor forvalidation. SHACL processors treat it as a general RDF graph and makes no assumption about its nature. For example, it can be an in-memory graph or a named graph from an RDF dataset or a SPARQL endpoint.

SHACL can be used with RDF graphs that are obtained by any means, e.g. from the file system, HTTP requests, orRDF datasets. SHACL makes no assumptions about whether a graph contains triples that are entailed from the graph under any RDF entailment regime.

The data graph is expected to include all the ontology axioms related to the data and especially all therdfs:subClassOf triples in order for SHACL to correctly identify class targets and validate Core SHACL constraints.

3.3Linking to shapes graphs (sh:shapesGraph)

Adata graph can include triples used to suggest one or more graphs to a SHACL processor with the predicatesh:shapesGraph.Everyvalue ofsh:shapesGraph is anIRI representing a graph thatSHOULD be included into theshapes graph used to validate thedata graph.

In the following example, a SHACL processorSHOULD use the union ofex:graph-shapes1 andex:graph-shapes2 graphs (and theirowl:imports) as theshapes graph when validating the given graph.

<http://example.com/myDataGraph>sh:shapesGraph ex:graph-shapes1 ;sh:shapesGraph ex:graph-shapes2 .

3.4Validation

Validation is a mapping from some input tovalidation results, as defined in the following paragraphs.

Validation of a data graph against a shapes graph: Given adata graph and ashapes graph, thevalidation results are the union of results of thevalidation of thedata graph against allshapes in theshapes graph.

Validation of a data graph against a shape: Given adata graph and ashape in theshapes graph, thevalidation results are the union of the results of thevalidation of allfocus nodes that are in thetarget of theshape in thedata graph.

Validation of a focus node against a shape: Given afocus node in thedata graph and ashape in theshapes graph, thevalidation results are the union of the results of thevalidation of thefocus node against allconstraints declared by theshape, unless theshape has beendeactivated, in which case thevalidation results are empty.

Validation of a focus node against a constraint: Given afocus node in thedata graph and aconstraint ofkindC in theshapes graph, thevalidation results are defined by thevalidators of theconstraint componentC. Thesevalidators typically take as input thefocus node, the specificvalues of theparameters ofC of theconstraint in theshapes graph, and thevalue nodes of theshape that declares the constraint.

During validation, thedata graph and theshapes graphMUST remain immutable, i.e. both graphs at the end of the validationMUST be identical to the graph at the beginning of validation. SHACL processorsMUST NOT change the graphs that they use to construct the shapes graph or the data graph, even if these graphs are part of an RDF store that allows changes to its stored graphs. SHACL processorsMAY store the graphs that they create, such as a graph containing validation results, and this operationMAY change existing graphs in an RDF store, but not any of the graphs that were used to construct the shapes graph or the data graph. SHACL processing is thus idempotent.

3.4.1Failures

Validation andconformance checking can result in afailure. For example, a particular SHACL processor might allow recursive shapes but report a failure if it detects a loop within the data. Failures can also be reported due to resource exhaustion. Failures are signalled through implementation-specific channels.

3.4.2Handling of Ill-formed Shapes Graphs

If theshapes graph containsill-formed nodes, then the result of the validation process isundefined. A SHACL processorSHOULD produce afailure in this case. See also3.6.1.3Syntax Checking of Shapes Graph (sh:shapesGraphWellFormed).

3.4.3Handling of Recursive Shapes

The following properties are the so-calledshape-expecting constraint parameters in SHACL Core:

The following properties are the so-calledlist-taking constraint parameters in SHACL Core:

A shapes1 in an RDF graphGrefers to shapes2 inG if it hass2 asvalue for some non-list-taking, shape-expecting parameter of some constraint component ors2 as amember of thevalue for some list-taking, shape-expecting parameter of some constraint component. A shape in an RDF graphG is arecursive shape inG if it is related to itself by the transitive closure of therefers relationship inG.

Thevalidation withrecursive shapes is not defined in SHACL and is left to SHACL processor implementations. For example, SHACL processors may support recursion scenarios or produce a failure when they detect recursion.

The remainder of this section is informative.

The recursion policy above has been selected to support a large variety of implementation strategies. By leaving recursion undefined, implementations may chose to not support recursion so that they can issue a static set of SPARQL queries (against SPARQL end points) without having to support cycles. The Working Group is aware that other implementations may support recursion and that some shapes graphs may rely on these specific characteristics. The expectation is that future work, for example inW3C Community Groups, will lead to the definition of specific dialects of SHACL where recursion is well-defined.

3.5Conformance Checking

Afocus nodeconforms to ashape if and only if the set of result of thevalidation of thefocus node against theshape is empty and nofailure has been reported by it.

Conformance checking producestrue if and only if a givenfocus nodeconforms to a givenshape, andfalse otherwise.

Note that someconstraint components of SHACL Core (e.g., those ofsh:not,sh:or andsh:node) rely on conformance checking. In these cases, thevalidation results used to determine the outcome of conformance checking are separated from those of the surrounding validation process and typically do not end up in the same validation report (except perhaps as values ofsh:detail).

3.6Validation Report

Thevalidation report is the result of thevalidation process that reports theconformance and the set of allvalidation results. The validation report is described with the SHACLValidation Report Vocabulary as defined in this section. This vocabulary defines the RDF properties to represent structural information that may provide guidance on how to identify or fix violations in the data graph.

SHACL-compliant processorsMUST be capable of returning a validation report with all requiredvalidation results described in this specification. SHACL-compliant processorsMAY support optional arguments that make it possible to limit the number of returned results. This flexibility is for example needed in some large-scale dataset validation use cases.

The following graph represents an example of a validation report for the validation of a data graph that conforms to a shapes graph.

[ a sh:ValidationReport ;sh:conforms true ;] .

The following graph represents an example of a validation report for the validation of a data graph that does not conform to a shapes graph. Note that the specific value ofsh:resultMessage is not mandated by SHACL and considered implementation-specific.

[a sh:ValidationReport ;sh:conforms false ;sh:result [a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Bob ;sh:resultPath ex:age ;sh:value "twenty two" ;sh:resultMessage "ex:age expects a literal of datatype xsd:integer." ;sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;sh:sourceShape ex:PersonShape-age ;]] .

3.6.1Validation Report (sh:ValidationReport)

The result of avalidation process is an RDF graph with exactly oneSHACL instance ofsh:ValidationReport. The RDF graphMAY contain additional information such as provenance metadata.

3.6.1.1Conforms (sh:conforms)

Each SHACL instance ofsh:ValidationReport in the results graph has exactly one value for the propertysh:conforms and the value is of datatypexsd:boolean. It represents the outcome of theconformance checking. The value ofsh:conforms istrue if and only if thevalidation did not produce anyvalidation results, andfalse otherwise.

3.6.1.2Result (sh:result)

For every validation result that is produced by avalidation process (except those mentioned in the context ofconformance checking), the SHACL instance ofsh:ValidationReport in the results graph has a value for the propertysh:result. Each value ofsh:result is aSHACL instance of the classsh:ValidationResult.

3.6.1.3Syntax Checking of Shapes Graph (sh:shapesGraphWellFormed)

SHACL validation engines are not strictly required to check whether theshapes graph iswell-formed. Implementations that do perform such checks (e.g., when the shapes graph is installed in the system, or before or during the validation)SHOULD use the propertysh:shapesGraphWellFormed to inform the consumer of the validation report about this fact. If a SHACL instance ofsh:ValidationReport in the results graph hastrue as thevalue forsh:shapesGraphWellFormed then theprocessor was certain that theshapes graph that was used for thevalidation process has passed all SHACL syntax rules (as summarized inB.Summary of SHACL Syntax Rules) during the validation process.

3.6.2Validation Result (sh:ValidationResult)

SHACL definessh:ValidationResult as a subclass ofsh:AbstractResult to report individual SHACLvalidation results. SHACL implementations may use otherSHACL subclasses ofsh:AbstractResult, for example, to report successfully completed constraint checks or accumulated results.

All the properties described in the remaining sub-sections of this section can be specified in ash:ValidationResult. The propertiessh:focusNode,sh:resultSeverity andsh:sourceConstraintComponent are the only properties that are mandatory for all validation results.

3.6.2.1Focus node (sh:focusNode)

Each validation result has exactly one value for the propertysh:focusNode that is equal to thefocus node that has caused the result. This is thefocus node that was validated when the validation result was produced.

3.6.2.2Path (sh:resultPath)

Validation results may have a value for the propertysh:resultPath pointing at awell-formedSHACL property path. For results produced by aproperty shape, thisSHACL property path is equivalent to thevalue ofsh:path of the shape, unless stated otherwise.

3.6.2.3Value (sh:value)

Validation results may include, as avalue of the propertysh:value, at most one RDF term that has caused the result. The textual definitions of the validators of the SHACL Core components specify how this value is constructed - often they are thevalue nodes that have violated a constraint.

3.6.2.4Source (sh:sourceShape)

Validation results may include, as the onlyvalue of the propertysh:sourceShape, theshape that the givensh:focusNode was validated against.

3.6.2.5Constraint Component (sh:sourceConstraintComponent)

Validation results have exactly one value for the propertysh:sourceConstraintComponent and this value is theIRI of theconstraint component that caused the result. For example, results produced due to a violation of a constraint based on a value ofsh:minCount would have the source constraint componentsh:MinCountConstraintComponent.

3.6.2.6Details (sh:detail)

The propertysh:detail may link a (parent) result with one or more SHACL instances ofsh:AbstractResult that can provide further details about the cause of the (parent) result. Depending on the capabilities of the SHACL processor, this may for example include violations of constraints that have been evaluated as part of conformance checking viash:node.

3.6.2.7Message (sh:resultMessage)

Validation results may have values for the propertysh:resultMessage, for example to communicate additional textual details to humans. Whilesh:resultMessage may have multiple values, there should not be two values with the same language tag. These values are produced by a validation engine based on the values ofsh:message of the constraints in the shapes graph, seeDeclaring Messages for a Shape. In cases where a constraint does not have any values forsh:message in the shapes graph the SHACL processorMAY automatically generate other values forsh:resultMessage.

3.6.2.8Severity (sh:resultSeverity)

Each validation result has exactly onevalue for the propertysh:resultSeverity, and this value is anIRI. The value is equal to thevalue ofsh:severity of theshape in theshapes graph that caused the result, defaulting tosh:Violation if nosh:severity has been specified for the shape.

3.7Value Nodes

Thevalidators of most constraint components use the concept ofvalue nodes, which is defined as follows:

4.Core Constraint Components

This section defines the built-in SHACL Coreconstraint components thatMUST be supported by all SHACL Core processors. The definition of each constraint component contains its IRI as well as a table of itsparameters. Unless stated otherwise, all these parameters aremandatory parameters. Shapes that violate any of the syntax rules enumerated in those parameter tables areill-formed.

Each constraint component also includes a textual definition, which describes thevalidator associated with the component. These textual definitions refer to the values of the parameters in the constraint by variables of the form$paramName whereparamName is the part of the parameter'sIRI after thesh: namespace. For example, the textual definition ofsh:ClassConstraintComponent refers to the value ofsh:class using the variable$class. Note that these validators define theonly validation results that are being produced by the component. Furthermore, the validators always producenew result nodes, i.e. when the textual definition states that "...there is a validation result..." then this refers to a distinct new node in a results graph.

The remainder of this section is informative.

The choice of constraint components that were included into the SHACL Core was made based on the requirements collected by the [shacl-ucr] document. Special attention was paid to the balance between trying to cover as many common use cases as possible and keeping the size of the Core language manageable. Not all use cases can be expressed by the Core language alone. Instead, SHACL-SPARQL provides an extension mechanism, described in the second part of this specification. It is expected that additional reusable libraries ofconstraint components will be maintained by third parties.

Unless stated otherwise, the Core constraint components can be used both inproperty shapes andnode shapes. Some constraint parameters have syntax rules attached to them that would makenode shapes that use these parametersill-formed. Examples of this includesh:minCount which is only supported forproperty shapes.

The SPARQL definitions in this section represent potentialvalidators. They are included for illustration purposes only and have no formal status otherwise. Many constraint components are written as SPARQL ASK queries. These queries are interpreted against eachvalue node, bound to the variablevalue. If an ASK query does not evaluate totrue for avalue node, then there is avalidation result based on the rules outlined in thesection on ASK-based validators. Constraint components that are described using a SELECT query are interpreted based on the rules outlined in thesection on SELECT-based validators. In particular, forproperty shapes, the variablePATH issubstituted with a path expression based on the value ofsh:path in the shape. All SPARQL queries also require the variable bindings and result variable mapping rules detailed in thesection on SPARQL-based Constraints. The variablethis represents the currently validatedfocus node. Based on the parameter IRIs on the tables,pre-bound variables are derived using the syntax rules forparameter names.

4.1Value Type Constraint Components

The constraint components in this section have in common that they can be used to restrict the type of value nodes. Note that it is possible to represent multiple value type alternatives usingsh:or.

4.1.1sh:class

The condition specified bysh:class is that eachvalue node is aSHACL instance of a given type.

Constraint Component IRI:sh:ClassConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:class The type of all value nodes.The values ofsh:class in a shape are IRIs.
TEXTUAL DEFINITION
For eachvalue node that is either aliteral, or a non-literal that is not aSHACL instance of$class in thedata graph, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

Note that multiple values forsh:class are interpreted as a conjunction, i.e. the values need to be SHACL instances of all of them.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {$value rdf:type/rdfs:subClassOf* $class .}
ex:ClassExampleShapea sh:NodeShape ;sh:targetNode ex:Bob, ex:Alice, ex:Carol ;sh:property [sh:path ex:address ;sh:class ex:PostalAddress ;] .
ex:Alice a ex:Person .ex:Bob ex:address [ a ex:PostalAddress ; ex:city ex:Berlin ] .ex:Carol ex:address [ ex:city ex:Cairo ] .

4.1.2sh:datatype

sh:datatype specifies a condition to be satisfied with regards to the datatype of eachvalue node.

Constraint Component IRI:sh:DatatypeConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:datatype The datatype of all value nodes (e.g.,xsd:integer).The values ofsh:datatype in a shape areIRIs.A shape has at most one value forsh:datatype.
TEXTUAL DEFINITION
For eachvalue node that is not aliteral, or is aliteral with a datatype that does not match$datatype, there is avalidation result with thevalue node assh:value. The datatype of a literal is determined following thedatatype function of SPARQL 1.1. Aliteral matches a datatype if theliteral's datatype has the sameIRI and, for the datatypes supported by SPARQL 1.1, is not anill-typed literal.

The remainder of this section is informative.

The values ofsh:datatype are typicallydatatypes, such asxsd:string. Note that usingrdf:langString as value ofsh:datatype can be used to test if value nodes have a language tag.

ex:DatatypeExampleShapea sh:NodeShape ;sh:targetNode ex:Alice, ex:Bob, ex:Carol ;sh:property [sh:path ex:age ;sh:datatype xsd:integer ;] .
ex:Alice ex:age "23"^^xsd:integer .ex:Bob ex:age "twenty two" .ex:Carol ex:age "23"^^xsd:int .

4.1.3sh:nodeKind

sh:nodeKind specifies a condition to be satisfied by the RDF node kind of eachvalue node.

Constraint Component IRI:sh:NodeKindConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:nodeKind The node kind (IRI, blank node, literal or combinations of these) of all value nodes.The values ofsh:nodeKind in a shape are one of the following six instances of the classsh:NodeKind:sh:BlankNode,sh:IRI,sh:Literalsh:BlankNodeOrIRI,sh:BlankNodeOrLiteral andsh:IRIOrLiteral.A shape has at most one value forsh:nodeKind.
TEXTUAL DEFINITION
For eachvalue node that does not match$nodeKind, there is avalidation result with thevalue node assh:value. AnyIRI matches onlysh:IRI,sh:BlankNodeOrIRI andsh:IRIOrLiteral. Anyblank node matches onlysh:BlankNode,sh:BlankNodeOrIRI andsh:BlankNodeOrLiteral. Anyliteral matches onlysh:Literal,sh:BlankNodeOrLiteral andsh:IRIOrLiteral.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER ((isIRI($value) && $nodeKind IN ( sh:IRI, sh:BlankNodeOrIRI, sh:IRIOrLiteral ) ) ||(isLiteral($value) && $nodeKind IN ( sh:Literal, sh:BlankNodeOrLiteral, sh:IRIOrLiteral ) ) ||(isBlank($value)   && $nodeKind IN ( sh:BlankNode, sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral ) )) .}

The following example states that all values ofex:knows need to be IRIs, at any subject.

ex:NodeKindExampleShapea sh:NodeShape ;sh:targetObjectsOf ex:knows ;sh:nodeKind sh:IRI .
ex:Bob ex:knows ex:Alice .ex:Alice ex:knows"Bob" .

4.2Cardinality Constraint Components

The followingconstraint components represent restrictions on the number ofvalue nodes for the givenfocus node.

4.2.1sh:minCount

sh:minCount specifies the minimum number ofvalue nodes that satisfy the condition. If the minimum cardinality value is 0 then this constraint is always satisfied and so may be omitted.

Constraint Component IRI:sh:MinCountConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:minCount The minimum cardinality.Node shapes cannot have any value forsh:minCount.Aproperty shape has at most one value forsh:minCount.The values ofsh:minCount in a property shape are literals with datatypexsd:integer.
TEXTUAL DEFINITION
If the number ofvalue nodes is less than$minCount, there is avalidation result.

The remainder of this section is informative.

ex:MinCountExampleShapea sh:PropertyShape ;sh:targetNode ex:Alice, ex:Bob ;sh:path ex:name ;sh:minCount 1 .
ex:Alice ex:name "Alice" .ex:Bob ex:givenName "Bob"@en .

4.2.2sh:maxCount

sh:maxCount specifies the maximum number ofvalue nodes that satisfy the condition.

Constraint Component IRI:sh:MaxCountConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:maxCount The maximum cardinality.Node shapes cannot have any value forsh:maxCount.Aproperty shape has at most one value forsh:maxCount.The values ofsh:maxCount in a property shape are literals with datatypexsd:integer.
TEXTUAL DEFINITION
If the number ofvalue nodes is greater than$maxCount, there is avalidation result.

The remainder of this section is informative.

ex:MaxCountExampleShapea sh:NodeShape ;sh:targetNode ex:Bob ;sh:property [sh:path ex:birthDate ;sh:maxCount 1 ;] .
ex:Bob ex:birthDate "May 5th 1990" .

4.3Value Range Constraint Components

The following constraint components specify value range conditions to be satisfied by value nodes that are comparable via operators such as<,<=,> and>=. The following example illustrates a typical use case of these constraint components.

ex:NumericRangeExampleShapea sh:NodeShape ;sh:targetNode ex:Bob, ex:Alice, ex:Ted ;sh:property [sh:path ex:age ;sh:minInclusive 0 ;sh:maxInclusive 150 ;] .
ex:Bob ex:age 23 .ex:Alice ex:age 220 .ex:Ted ex:age "twenty one" .

4.3.1sh:minExclusive

Constraint Component IRI:sh:MinExclusiveConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:minExclusive The minimum exclusive value.The values ofsh:minExclusive in a shape areliterals.A shape has at most one value forsh:minExclusive.
TEXTUAL DEFINITION
For eachvalue nodev where the SPARQL expression$minExclusive < v does not returntrue, there is avalidation result withv assh:value.

The remainder of this section is informative.

The SPARQL expression produces an error if the value node cannot be compared to the specified range, for example when someone compares a string with an integer. If the comparison cannot be performed, then there is a validation result. This is different from, say, a plain SPARQL query, in which such errors would silently not lead to any results.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER ($minExclusive < $value)}

4.3.2sh:minInclusive

Constraint Component IRI:sh:MinInclusiveConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:minInclusive The minimum inclusive value.The values ofsh:minInclusive in a shape areliterals.A shape has at most one value forsh:minInclusive.
TEXTUAL DEFINITION
For eachvalue nodev where the SPARQL expression$minInclusive <= v does not returntrue, there is avalidation result withv assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER ($minInclusive <= $value)}

4.3.3sh:maxExclusive

Constraint Component IRI:sh:MaxExclusiveConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:maxExclusive The maximum exclusive value.The values ofsh:maxExclusive in a shape areliterals.A shape has at most one value forsh:maxExclusive.
TEXTUAL DEFINITION
For eachvalue nodev where the SPARQL expression$maxExclusive > v does not returntrue, there is avalidation result withv assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER ($maxExclusive > $value)}

4.3.4sh:maxInclusive

Constraint Component IRI:sh:MaxInclusiveConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:maxInclusive The maximum inclusive value.The values ofsh:maxInclusive in a shape areliterals.A shape has at most one value forsh:maxInclusive.
TEXTUAL DEFINITION
For eachvalue nodev where the SPARQL expression$maxInclusive >= v does not returntrue, there is avalidation result withv assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER ($maxInclusive >= $value)}

4.4String-based Constraint Components

The constraint components in this section have in common that they specify conditions on the string representation ofvalue nodes.

4.4.1sh:minLength

sh:minLength specifies the minimum string length of eachvalue node that satisfies the condition. This can be applied to anyliterals andIRIs, but not toblank nodes.

Constraint Component IRI:sh:MinLengthConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:minLength The minimum length.The values ofsh:minLength in a shape are literals with datatypexsd:integer.A shape has at most one value forsh:minLength.
TEXTUAL DEFINITION
For eachvalue nodev where the length (as defined by theSPARQL STRLEN function) of the string representation ofv (as defined by theSPARQL str function) is less than$minLength, or wherev is ablank node, there is avalidation result withv assh:value.

The remainder of this section is informative.

Note that if the value ofsh:minLength is 0 then there is no restriction on the string length but the constraint is still violated if the value node is a blank node.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER (STRLEN(str($value)) >= $minLength) .}

4.4.2sh:maxLength

sh:maxLength specifies the maximum string length of eachvalue node that satisfies the condition. This can be applied to anyliterals andIRIs, but not toblank nodes.

Constraint Component IRI:sh:MaxLengthConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:maxLength The maximum length.The values ofsh:maxLength in a shape are literals with datatypexsd:integer.A shape has at most one value forsh:maxLength.
TEXTUAL DEFINITION
For eachvalue nodev where the length (as defined by theSPARQL STRLEN function) of the string representation ofv (as defined by theSPARQL str function) is greater than$maxLength, or wherev is ablank node, there is avalidation result withv assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER (STRLEN(str($value)) <= $maxLength) .}
ex:PasswordExampleShapea sh:NodeShape ;sh:targetNode ex:Bob, ex:Alice ;sh:property [sh:path ex:password ;sh:minLength 8 ;sh:maxLength 10 ;] .
ex:Bob ex:password "123456789" .ex:Alice ex:password "1234567890ABC" .

4.4.3sh:pattern

sh:pattern specifies a regular expression that eachvalue node matches to satisfy the condition.

Constraint Component IRI:sh:PatternConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:pattern A regular expression that all value nodes need to match.The values ofsh:pattern in a shape are literals with datatypexsd:string.The values ofsh:pattern in a shape are valid pattern arguments for theSPARQL REGEX function.
sh:flags An optional string of flags, interpreted as inSPARQL 1.1 REGEX.The values ofsh:flags in a shape are literals with datatypexsd:string.
TEXTUAL DEFINITION
For eachvalue node that is a blank node or where the string representation (as defined by theSPARQL str function) does not match the regular expression$pattern (as defined by theSPARQL REGEX function), there is avalidation result with thevalue node assh:value. If$flags has a value then the matchingMUST follow the definition of the 3-argument variant of the SPARQL REGEX function, using$flags as third argument.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {FILTER (!isBlank($value) && IF(bound($flags), regex(str($value), $pattern, $flags), regex(str($value), $pattern)))}
ex:PatternExampleShapea sh:NodeShape ;sh:targetNode ex:Bob, ex:Alice, ex:Carol ;sh:property [sh:path ex:bCode ;sh:pattern "^B" ;    # starts with 'B'sh:flags "i" ;       # Ignore case] .
ex:Bob ex:bCode "b101" .ex:Alice ex:bCode "B102" .ex:Carol ex:bCode "C103" .

4.4.4sh:languageIn

The condition specified bysh:languageIn is that the allowed language tags for eachvalue node are limited by a given list of language tags.

Constraint Component IRI:sh:LanguageInConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:languageIn A list of basic language ranges as per [BCP47].Each value ofsh:languageIn in a shape is aSHACL list.Eachmember of such a list is a literal with datatypexsd:string.A shape has at most one value forsh:languageIn.
TEXTUAL DEFINITION
For eachvalue node that is either not aliteral or that does not have a language tag matching any of the basic language ranges that are themembers of$languageIn following the filtering schema defined by theSPARQL langMatches function, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

The following example shape states that all values ofex:prefLabel can be either in English or Māori.

ex:NewZealandLanguagesShapea sh:NodeShape ;sh:targetNode ex:Mountain, ex:Berg ;sh:property [sh:path ex:prefLabel ;sh:languageIn ( "en" "mi" ) ;] .

From the example instances,ex:Berg will lead to constraint violations for all of its labels.

ex:Mountainex:prefLabel "Mountain"@en ;ex:prefLabel "Hill"@en-NZ ;ex:prefLabel "Maunga"@mi .ex:Bergex:prefLabel "Berg" ;ex:prefLabel "Berg"@de ;ex:prefLabel ex:BergLabel .

4.4.5sh:uniqueLang

The propertysh:uniqueLang can be set totrue to specify that no pair ofvalue nodes may use the same language tag.

Constraint Component IRI:sh:UniqueLangConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:uniqueLangtrue to activate this constraint.The values ofsh:uniqueLang in a shape are literals with datatypexsd:boolean.A property shape has at most one value forsh:uniqueLang.Node shapes cannot have any value forsh:uniqueLang.
TEXTUAL DEFINITION
If$uniqueLang istrue then for each non-empty language tag that is used by at least twovalue nodes, there is avalidation result.

The remainder of this section is informative.

ex:UniqueLangExampleShapea sh:NodeShape ;sh:targetNode ex:Alice, ex:Bob ;sh:property [sh:path ex:label ;sh:uniqueLang true ;] .
ex:Aliceex:label "Alice" ;ex:label "Alice"@en ;ex:label "Alice"@fr .ex:Bobex:label "Bob"@en ;ex:label "Bobby"@en .

4.5Property Pair Constraint Components

The constraint components in this section specify conditions on the sets ofvalue nodes in relation to other properties. These constraint components can only be used byproperty shapes.

4.5.1sh:equals

sh:equals specifies the condition that the set of allvalue nodes is equal to the set ofobjects of thetriples that have thefocus node assubject and thevalue ofsh:equals aspredicate.

Constraint Component IRI:sh:EqualsConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:equals The property to compare with.The values ofsh:equals in a shape areIRIs.
TEXTUAL DEFINITION
For eachvalue node that does not exist as avalue of the property$equals at thefocus node, there is avalidation result with thevalue node assh:value. For eachvalue of the property$equals at thefocus node that is not one of thevalue nodes, there is avalidation result with thevalue assh:value.

The remainder of this section is informative.

The following example illustrates the use ofsh:equals in a shape to specify that certain focus nodes need to have the same set of values forex:firstName andex:givenName.

ex:EqualExampleShapea sh:NodeShape ;sh:targetNode ex:Bob ;sh:property [sh:path ex:firstName ;sh:equals ex:givenName ;] .
ex:Bobex:firstName "Bob" ;ex:givenName "Bob" .

4.5.2sh:disjoint

sh:disjoint specifies the condition that the set ofvalue nodes is disjoint with the set ofobjects of thetriples that have thefocus node assubject and thevalue ofsh:disjoint aspredicate.

Constraint Component IRI:sh:DisjointConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:disjoint The property to compare the values with.The values ofsh:disjoint in a shape areIRIs.
TEXTUAL DEFINITION
For eachvalue node that also exists as avalue of the property$disjoint at thefocus node, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must return no results for the given $PATH)
SELECT DISTINCT $this ?valueWHERE {$this $PATH ?value .$this $disjoint ?value .}

The following example illustrates the use ofsh:disjoint in a shape to specify that certain focus nodes cannot share any values forex:prefLabel andex:altLabel.

ex:DisjointExampleShapea sh:NodeShape ;sh:targetNode ex:USA, ex:Germany ;sh:property [sh:path ex:prefLabel ;sh:disjoint ex:altLabel ;] .
ex:USAex:prefLabel "USA" ;ex:altLabel "United States" .ex:Germanyex:prefLabel "Germany" ;ex:altLabel "Germany" .

4.5.3sh:lessThan

sh:lessThan specifies the condition that eachvalue node is smaller than all theobjects of thetriples that have thefocus node assubject and thevalue ofsh:lessThan aspredicate.

Constraint Component IRI:sh:LessThanConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:lessThan The property to compare the values with.The values ofsh:lessThan in a shape areIRIs.Node shapes cannot have any value forsh:lessThan.
TEXTUAL DEFINITION
For each pair ofvalue nodes and the values of the property$lessThan at the givenfocus node where the firstvalue is not less than the secondvalue (based on SPARQL's< operator) or where the two values cannot be compared, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must return no results for the given $PATH)
SELECT $this ?valueWHERE {$this $PATH ?value .$this $lessThan ?otherValue .BIND (?value < ?otherValue AS ?result) .FILTER (!bound(?result) || !(?result)) .}

The following example illustrates the use ofsh:lessThan in a shape to specify that all values ofex:startDate are "before" the values ofex:endDate.

ex:LessThanExampleShapea sh:NodeShape ;sh:property [sh:path ex:startDate ;sh:lessThan ex:endDate ;] .

4.5.4sh:lessThanOrEquals

sh:lessThanOrEquals specifies the condition that eachvalue node is smaller than or equal to all theobjects of thetriples that have thefocus node assubject and thevalue ofsh:lessThanOrEquals aspredicate.

Constraint Component IRI:sh:LessThanOrEqualsConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:lessThanOrEquals The property to compare the values with.The values ofsh:lessThanOrEquals in a shape areIRIs.Node shapes cannot have any value forsh:lessThanOrEquals.
TEXTUAL DEFINITION
For each pair ofvalue nodes and the values of the property$lessThanOrEquals at the givenfocus node where the firstvalue is not less than or equal to the secondvalue (based on SPARQL's<= operator) or where the two values cannot be compared, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

POTENTIAL DEFINITION IN SPARQL (Must return no results for the given $PATH)
SELECT $this ?valueWHERE {$this $PATH ?value .$this $lessThan ?otherValue .BIND (?value <= ?otherValue AS ?result) .FILTER (!bound(?result) || !(?result)) .}

4.6Logical Constraint Components

The constraint components in this section implement the common logical operatorsand,or andnot, as well as a variation ofexclusive or.

4.6.1sh:not

sh:not specifies the condition that eachvalue node cannotconform to a givenshape. This is comparable to negation and the logical "not" operator.

Constraint Component IRI:sh:NotConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:not The shape to negate.The values ofsh:not in a shape must bewell-formedshapes.
TEXTUAL DEFINITION
For eachvalue nodev: AfailureMUST be reported if theconformance checking ofv against the shape$not produces afailure. Otherwise, ifvconforms to the shape$not, there isvalidation result withv assh:value.

The remainder of this section is informative.

The following example illustrates the use ofsh:not in a shape to specify the condition that certain focus nodes cannot have any value ofex:property.

ex:NotExampleShapea sh:NodeShape ;sh:targetNode ex:InvalidInstance1 ;sh:not [a sh:PropertyShape ;sh:path ex:property ;sh:minCount 1 ;] .
ex:InvalidInstance1 ex:property "Some value" .

4.6.2sh:and

sh:and specifies the condition that eachvalue node conforms to all provided shapes. This is comparable to conjunction and the logical "and" operator.

Constraint Component IRI:sh:AndConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:and ASHACL list of shapes to validate the value nodes against.Each value ofsh:and in a shape is aSHACL list.Eachmember of such list must be awell-formedshape.
TEXTUAL DEFINITION
For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against any of themembers of$and produces afailure. Otherwise, ifv does notconform to eachmember of$and, there is avalidation result withv assh:value.

The remainder of this section is informative.

Note that althoughsh:and has aSHACL list of shapes as its value, the order of those shapes does not impact the validation results.

The following example illustrates the use ofsh:and in a shape to specify the condition that certain focus nodes have exactly one value ofex:property. This is achieved via the conjunction of a separate named shape (ex:SuperShape) which specifies the minimum count, and a blank node shape that additionally specifies the maximum count. As shown here,sh:and can be used to implement a specialization mechanism between shapes.

ex:SuperShapea sh:NodeShape ;sh:property [sh:path ex:property ;sh:minCount 1 ;] .ex:ExampleAndShapea sh:NodeShape ;sh:targetNode ex:ValidInstance, ex:InvalidInstance ;sh:and (ex:SuperShape[sh:path ex:property ;sh:maxCount 1 ;]) .
ex:ValidInstanceex:property "One" .# Invalid: more than one propertyex:InvalidInstanceex:property "One" ;ex:property "Two" .

4.6.3sh:or

sh:or specifies the condition that eachvalue node conforms to at least one of the provided shapes. This is comparable to disjunction and the logical "or" operator.

Constraint Component IRI:sh:OrConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:or ASHACL list of shapes to validate the value nodes against.Each value ofsh:or in a shape is aSHACL list.Eachmember of such list must be awell-formedshape.
TEXTUAL DEFINITION
For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against any of themembers produces afailure. Otherwise, ifvconforms to none of themembers of$or there is avalidation result withv assh:value.

The remainder of this section is informative.

Note that althoughsh:or has aSHACL list of shapes as its value, the order of those shapes does not impact the validation results.

The following example illustrates the use ofsh:or in a shape to specify the condition that certain focus nodes have at least one value ofex:firstName or at least one value ofex:givenName.

ex:OrConstraintExampleShapea sh:NodeShape ;sh:targetNode ex:Bob ;sh:or ([sh:path ex:firstName ;sh:minCount 1 ;][sh:path ex:givenName ;sh:minCount 1 ;]) .
ex:Bob ex:firstName "Robert" .

The next example shows howsh:or can be used in aproperty shape to state that the values of the given propertyex:address may be either literals with datatypexsd:string orSHACL instances of the classex:Address.

ex:PersonAddressShapea sh:NodeShape ;sh:targetClass ex:Person ;sh:property [sh:path ex:address ;sh:or ([sh:datatype xsd:string ;][sh:class ex:Address ;])] .
ex:Bob ex:address "123 Prinzengasse, Vaduz, Liechtenstein" .

4.6.4sh:xone

sh:xone specifies the condition that eachvalue node conforms toexactly one of the provided shapes.

Constraint Component IRI:sh:XoneConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:xone ASHACL list of shapes to validate the value nodes against.Each value ofsh:xone in a shape is aSHACL list.Eachmember of such list must be awell-formedshape.
TEXTUAL DEFINITION
For eachvalue nodev letN be the number of theshapes that aremembers of$xone wherevconforms to the shape. AfailureMUST be produced if theconformance checking ofv against any of themembers produces afailure. Otherwise, ifN is not exactly1, there is avalidation result withv assh:value.

The remainder of this section is informative.

Note that althoughsh:xone has aSHACL list of shapes as its value, the order of those shapes does not impact the validation results.

The following example illustrates the use ofsh:xone in a shape to specify the condition that certain focus nodes must either have a value forex:fullName or values forex:firstName andex:lastName, but not both.

ex:XoneConstraintExampleShapea sh:NodeShape ;sh:targetClass ex:Person ;sh:xone ([sh:property [sh:path ex:fullName ;sh:minCount 1 ;]][sh:property [sh:path ex:firstName ;sh:minCount 1 ;] ;sh:property [sh:path ex:lastName ;sh:minCount 1 ;]]) .
ex:Bob a ex:Person ;ex:firstName "Robert" ; ex:lastName "Coin" .ex:Carla a ex:Person ;ex:fullName "Carla Miller" .ex:Dory a ex:Person ;ex:firstName "Dory" ;ex:lastName "Dunce" ;ex:fullName "Dory Dunce" .

4.7Shape-based Constraint Components

The constraint components in this section can be used to specify complex conditions by validating the value nodes against certain shapes.

4.7.1sh:node

sh:node specifies the condition that eachvalue node conforms to the givennode shape.

Constraint Component IRI:sh:NodeConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:node Thenode shape that all value nodes need to conform to.The values ofsh:node in a shape must bewell-formednode shapes.
TEXTUAL DEFINITION
For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against$node produces afailure. Otherwise, ifv does notconform to$node, there is avalidation result withv assh:value.

The remainder of this section is informative.

In the following example, all values of the propertyex:address must fulfill the constraints expressed by theshapeex:AddressShape.

ex:AddressShapea sh:NodeShape ;sh:property [sh:path ex:postalCode ;sh:datatype xsd:string ;sh:maxCount 1 ;] .ex:PersonShapea sh:NodeShape ;sh:targetClass ex:Person ;sh:property [   # _:b1sh:path ex:address ;sh:minCount 1 ;sh:node ex:AddressShape ;] .
ex:Bob a ex:Person ;ex:address ex:BobsAddress .ex:BobsAddressex:postalCode "1234" .ex:Reto a ex:Person ;ex:address ex:RetosAddress .ex:RetosAddressex:postalCode 5678 .
[a sh:ValidationReport ;sh:conforms false ;sh:result [a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:Reto ;sh:resultPath ex:address ;sh:value ex:RetosAddress ;sh:resultMessage "Value does not conform to shape ex:AddressShape." ;sh:sourceConstraintComponent sh:NodeConstraintComponent ;sh:sourceShape _:b1 ;]] .

4.7.2sh:property

sh:property can be used to specify that eachvalue node has a givenproperty shape.

Constraint Component IRI:sh:PropertyShapeComponent

Parameters:
PropertySummary and Syntax Rules
sh:property Aproperty shape that all value nodes need to have.Each value ofsh:property in a shape must be awell-formedproperty shape.
TEXTUAL DEFINITION
For eachvalue nodev: AfailureMUST be produced if the validation ofv asfocus node against the property shape$property produces afailure. Otherwise, the validation results are the results ofvalidatingv asfocus node against the property shape$property.

The remainder of this section is informative.

Note that there is an important difference betweensh:property andsh:node: If a value node is violating the constraint, then there is only a single validation result forsh:node for this value node, withsh:NodeConstraintComponent as itssh:sourceConstraintComponent. On the other hand side, there may be any number of validation results forsh:property, and these will have the individual constraint components of theconstraints in theproperty shape as their values ofsh:sourceConstraintComponent.

Like with all other validation results, each time aproperty shape is reached viash:property, a validation engineMUST producefresh validation result nodes. This includes cases where the samefocus node is validated against the sameproperty shape although it is reached via different paths in theshapes graph.

4.7.3sh:qualifiedValueShape, sh:qualifiedMinCount, sh:qualifiedMaxCount

sh:qualifiedValueShape specifies the condition that a specified number ofvalue nodes conforms to the given shape. Eachsh:qualifiedValueShape can have: one value forsh:qualifiedMinCount, one value forsh:qualifiedMaxCount or, one value for each, at the samesubject.

Parameters:
PropertySummary and Syntax Rules
sh:qualifiedValueShape The shape that the specified number of value nodes needs to conform to.The values ofsh:qualifiedValueShape in a shape must bewell-formedshapes.Node shapes cannot have any value forsh:qualifiedValueShape. This is amandatory parameter ofsh:QualifiedMinCountConstraintComponent andsh:QualifiedMaxCountConstraintComponent.
sh:qualifiedValueShapesDisjoint This is anoptional parameter ofsh:QualifiedMinCountConstraintComponent andsh:QualifiedMaxCountConstraintComponent. If set totrue then (for the counting) the value nodes must not conform to any of thesibling shapes.The values ofsh:qualifiedValueShapesDisjoint in a shape are literals with datatypexsd:boolean.
sh:qualifiedMinCount The minimum number of value nodes that conform to the shape.The values ofsh:qualifiedMinCount in a shape are literals with datatypexsd:integer. This is amandatory parameter ofsh:QualifiedMinCountConstraintComponent.
sh:qualifiedMaxCount The maximum number of value nodes that can conform to the shape.The values ofsh:qualifiedMaxCount in a shape are literals with datatypexsd:integer. This is amandatory parameter ofsh:QualifiedMaxCountConstraintComponent.
TEXTUAL DEFINITION of Sibling Shapes
LetQ be ashape inshapes graphG that declares a qualified cardinality constraint (by having values forsh:qualifiedValueShape and at least one ofsh:qualifiedMinCount orsh:qualifiedMaxCount). Letps be the set ofshapes inG that haveQ as avalue ofsh:property. IfQ hastrue as avalue forsh:qualifiedValueShapesDisjoint then the set ofsibling shapes forQ is defined as the set of allvalues of theSPARQL property pathsh:property/sh:qualifiedValueShape for anyshape inps minus thevalue ofsh:qualifiedValueShape ofQ itself. The set of sibling shapes is empty otherwise.
TEXTUAL DEFINITION of sh:qualifiedMinCount
LetC be the number ofvalue nodesv wherevconforms to$qualifiedValueShape and wherev does notconform to any of thesibling shapes for thecurrent shape, i.e. the shape thatv is validated against and which has$qualifiedValueShape as its value forsh:qualifiedValueShape. AfailureMUST be produced if any of the said conformance checks produces afailure. Otherwise, there is avalidation result ifC is less than$qualifiedMinCount. Theconstraint component forsh:qualifiedMinCount issh:QualifiedMinCountConstraintComponent.
TEXTUAL DEFINITION of sh:qualifiedMaxCount
LetC be as defined forsh:qualifiedMinCount above. AfailureMUST be produced if any of the said conformance checks produces afailure. Otherwise, there is avalidation result ifC is greater than$qualifiedMaxCount. Theconstraint component forsh:qualifiedMaxCount issh:QualifiedMaxCountConstraintComponent.

The remainder of this section is informative.

In the following example shape can be used to specify the condition that the propertyex:parent has exactly two values, and at least one of them is female.

ex:QualifiedValueShapeExampleShapea sh:NodeShape ;sh:targetNode ex:QualifiedValueShapeExampleValidResource ;sh:property [sh:path ex:parent ;sh:minCount 2 ;sh:maxCount 2 ;sh:qualifiedValueShape [sh:path ex:gender ;sh:hasValue ex:female ;] ;sh:qualifiedMinCount 1 ;] .
ex:QualifiedValueShapeExampleValidResourceex:parent ex:John ;ex:parent ex:Jane .ex:Johnex:gender ex:male .ex:Janeex:gender ex:female .

The following example illustrates the use ofsh:qualifiedValueShapesDisjoint to express that a hand must have at most 5 values ofex:property (expressed usingsh:maxCount), and exactly one of them must be an instance ofex:Thumb while exactly 4 of them must be an instance ofex:Finger but thumbs and fingers must be disjoint. In other words, on a hand, none of the fingers can also be counted as the thumb.

ex:HandShapea sh:NodeShape ;sh:targetClass ex:Hand ;sh:property [sh:path ex:digit ;sh:maxCount 5 ;] ;sh:property [sh:path ex:digit ;sh:qualifiedValueShape [ sh:class ex:Thumb ] ;sh:qualifiedValueShapesDisjoint true ;sh:qualifiedMinCount 1 ;sh:qualifiedMaxCount 1 ;] ;sh:property [sh:path ex:digit ;sh:qualifiedValueShape [ sh:class ex:Finger ] ;sh:qualifiedValueShapesDisjoint true ;sh:qualifiedMinCount 4 ;sh:qualifiedMaxCount 4 ;] .

4.8Other Constraint Components

This section enumerates Core constraint components that do not fit into the other categories.

4.8.1sh:closed, sh:ignoredProperties

The RDF data model offers a huge amount of flexibility. Any node can in principle have values for any property. However, in some cases it makes sense to specify conditions on which properties can be applied to nodes. The SHACL Core language includes a property calledsh:closed that can be used to specify the condition that each value node hasvalues only for those properties that have been explicitly enumerated via theproperty shapes specified for the shape viash:property.

Constraint Component IRI:sh:ClosedConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:closed Set totrue to close the shape.The values ofsh:closed in a shape are literals with datatypexsd:boolean.
sh:ignoredProperties OptionalSHACL list of properties that are also permitted in addition to those explicitly enumerated viash:property.The values ofsh:ignoredProperties in a shape must beSHACL lists.Eachmember of such a list must be aIRI.
TEXTUAL DEFINITION
If$closed istrue then there is avalidation result for eachtriple that has avalue node as itssubject and apredicate that is not explicitly enumerated as avalue ofsh:path in any of theproperty shapes declared viash:property at the current shape. If$ignoredProperties has a value then the properties enumerated asmembers of thisSHACL list are also permitted for thevalue node. Thevalidation resultMUST have thepredicate of the triple as itssh:resultPath, and theobject of the triple as itssh:value.

The remainder of this section is informative.

The following example illustrates the use ofsh:closed in a shape to specify the condition that certain focus nodes only have values forex:firstName andex:lastName. The "ignored" propertyrdf:type would also be allowed.

ex:ClosedShapeExampleShapea sh:NodeShape ;sh:targetNode ex:Alice, ex:Bob ;sh:closed true ;sh:ignoredProperties (rdf:type) ;sh:property [sh:path ex:firstName ;] ;sh:property [sh:path ex:lastName ;] .
ex:Aliceex:firstName "Alice" .ex:Bobex:firstName "Bob" ;ex:middleInitial "J" .

4.8.2sh:hasValue

sh:hasValue specifies the condition that at least onevalue node is equal to the given RDF term.

Constraint Component IRI:sh:HasValueConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:hasValue A specific required value.
TEXTUAL DEFINITION
If the RDF term$hasValue is not among thevalue nodes, there is avalidation result.

The remainder of this section is informative.

ex:StanfordGraduatea sh:NodeShape ;sh:targetNode ex:Alice ;sh:property [sh:path ex:alumniOf ;sh:hasValue ex:Stanford ;] .
ex:Aliceex:alumniOf ex:Harvard ;ex:alumniOf ex:Stanford .

4.8.3sh:in

sh:in specifies the condition that eachvalue node is amember of a providedSHACL list.

Constraint Component IRI:sh:InConstraintComponent

Parameters:
PropertySummary and Syntax Rules
sh:in ASHACL list that has the allowed values asmembers.Each value ofsh:in in a shape is aSHACL list.A shape has at most one value forsh:in.
TEXTUAL DEFINITION
For eachvalue node that is not amember of$in, there is avalidation result with thevalue node assh:value.

The remainder of this section is informative.

Note that matching of literals needs to be exact, e.g."04"^^xsd:byte does not match"4"^^xsd:integer.

POTENTIAL DEFINITION IN SPARQL (Must evaluate to true for each value node $value)
ASK {GRAPH $shapesGraph {$in (rdf:rest*)/rdf:first $value .}}
ex:InExampleShapea sh:NodeShape ;sh:targetNode ex:RainbowPony ;sh:property [sh:path ex:color ;sh:in ( ex:Pink ex:Purple ) ;] .
ex:RainbowPony ex:color ex:Pink .

Part 2: SHACL-SPARQL

Part 1 of this specification introduced features that are built into the Core of SHACL. The goal of this Core is to provide a high-level vocabulary for common use cases to describe shapes. However, SHACL also provides mechanisms to go beyond the Core vocabulary and represent constraints with greater flexibility. These mechanisms, calledSHACL-SPARQL, are described in the following sections.

5.SPARQL-based Constraints

SHACL-SPARQL supports aconstraint component that can be used to express restrictions based on a SPARQL SELECT query.

Constraint Component IRI:sh:SPARQLConstraintComponent

Parameters:
PropertySummary
sh:sparqlASPARQL-based constraint declaring the SPARQL query to evaluate.

Thesyntax rules andvalidation process for SPARQL-based constraints are defined in the rest of this section.

5.1An Example SPARQL-based Constraint

This section is non-normative.

The following example illustrates the syntax of aSPARQL-based constraint.

ex:ValidCountry a ex:Country ;ex:germanLabel "Spanien"@de .ex:InvalidCountry a ex:Country ;ex:germanLabel "Spain"@en .
ex:LanguageExampleShapea sh:NodeShape ;sh:targetClass ex:Country ;sh:sparql [a sh:SPARQLConstraint ;   # This triple is optionalsh:message "Values are literals with German language tag." ;sh:prefixes ex: ;sh:select """SELECT $this (ex:germanLabel AS ?path) ?valueWHERE {$this ex:germanLabel ?value .FILTER (!isLiteral(?value) || !langMatches(lang(?value), "de"))}""" ;] .

The target of the shape above includes allSHACL instances ofex:Country. For those nodes (represented by the variablethis), the SPARQL query walks through the values ofex:germanLabel and verifies that they are literals with a German language code. The validation results for the aforementioned data graph is shown below:

[a sh:ValidationReport ;sh:conforms false ;sh:result [a sh:ValidationResult ;sh:resultSeverity sh:Violation ;sh:focusNode ex:InvalidCountry ;sh:resultPath ex:germanLabel ;sh:value "Spain"@en ;sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;sh:sourceShape ex:LanguageExampleShape ;# ...]] .

The SPARQL query returns result setsolutions for all bindings of the variablevalue that violate the constraint. There is a validation result for eachsolution in that result set, applying themapping rules explained later. In this example, each validation result will have thebinding for the variablethis as thesh:focusNode,ex:germanLabel assh:resultPath and the violating value assh:value.

The following example illustrates a similar scenario as above, but with aproperty shape.

ex:LanguageExamplePropertyShapea sh:PropertyShape ;sh:targetClass ex:Country ;sh:path ex:germanLabel ;sh:sparql [a sh:SPARQLConstraint ;   # This triple is optionalsh:message "Values are literals with German language tag." ;sh:prefixes ex: ;sh:select """SELECT $this ?valueWHERE {$this $PATH ?value .FILTER (!isLiteral(?value) || !langMatches(lang(?value), "de"))}""" ;] .

5.2Syntax of SPARQL-based Constraints

Shapes may have values for the propertysh:sparql, and these values are eitherIRIs orblank nodes. These values are calledSPARQL-based constraints.

SPARQL-based constraints have exactly onevalue for the propertysh:select.The value ofsh:select is aliteral of datatypexsd:string. The classsh:SPARQLConstraint is defined in the SHACL vocabulary and may be used as thetype of these constraints (although no type is required).Using theprefix handling rules, the value ofsh:select is a valid SPARQL 1.1 SELECT query.The SPARQL query derived from the value ofsh:selectprojects the variablethis in the SELECT clause.

The following two properties are similar to their use inshapes:

SPARQL-based constraints may have values for the propertysh:message and these are eitherxsd:string literals or literals with a language tag.SPARQL-based constraints may have at most one value for the propertysh:deactivated and this value is eithertrue orfalse.

SELECT queries used in the context ofproperty shapes use a special variable namedPATH as a placeholder for the path used by the shape.

The only legal use of the variablePATH in the SPARQL queries ofSPARQL-based constraintsandSELECT-based validators is in thepredicate position of atriple pattern. A query that uses the variablePATH in any other position isill-formed.

5.2.1Prefix Declarations for SPARQL Queries

Ashapes graph may include declarations of namespace prefixes so that these prefixes can be used to abbreviate the SPARQL queries derived from the same shapes graph. The syntax of such prefix declarations is illustrated by the following example.

ex:a owl:Ontology ;owl:imports sh: ;sh:declare [sh:prefix "ex" ;sh:namespace "http://example.com/ns#"^^xsd:anyURI ;] ;sh:declare [sh:prefix "schema" ;sh:namespace "http://schema.org/"^^xsd:anyURI ;] .

Thevalues of the propertysh:declare areIRIs orblank nodes, and these values are calledprefix declarations. The SHACL vocabulary includes the classsh:PrefixDeclaration as type for suchprefix declarations although nordf:type triple is required for them.Prefix declarations have exactly one value for the propertysh:prefix.The values ofsh:prefix areliterals of datatypexsd:string.Prefix declarations have exactly one value for the propertysh:namespace.The values ofsh:namespace areliterals of datatypexsd:anyURI. Such a pair of values specifies a single mapping of a prefix to a namespace.

The recommendedsubject for values ofsh:declare is the IRI of the named graph containing the shapes that use the prefixes. These IRIs are often declared as an instance ofowl:Ontology, but this is not required.

Prefix declarations can be used bySPARQL-based constraints, thevalidators ofSPARQL-based constraint components, and by similar features defined by SHACL extensions. These nodes can use the propertysh:prefixes to specify a set of prefix mappings. An example use of thesh:prefixes property can be found in theexample above.

The values ofsh:prefixes are eitherIRIs orblank nodes.A SHACL processor collects a set of prefix mappings as the union of allindividual prefix mappings that arevalues of theSPARQL property pathsh:prefixes/owl:imports*/sh:declareof theSPARQL-based constraint orvalidator.If such a collection of prefix declarations contains multiple namespaces for the samevalue ofsh:prefix,then theshapes graph isill-formed. (Note that SHACL processorsMAY ignore prefix declarations that are never reached).

A SHACL processor transforms the values ofsh:select (and similar properties such assh:ask) into SPARQL by prependingPREFIX declarations for all prefix mappings. Each value ofsh:prefix is turned into thePNAME_NS, while each value ofsh:namespace is turned into theIRIREF in thePREFIX declaration. For the example shapes graph above, a SHACL-SPARQL processor would produce lines such asPREFIX ex: <http://example.com/ns#>. The SHACL-SPARQL processorMUST produce afailure if the resulting query string cannot be parsed into a valid SPARQL 1.1 query.

In the rest of this document, thesh:prefixes statements may have been omitted for brevity.

5.3Validation with SPARQL-based Constraints

This section explains thevalidator ofsh:SPARQLConstraintComponent. Note that this validator only explains one possible implementation strategy, and SHACL processors may choose alternative approaches as long as the outcome is equivalent.

TEXTUAL DEFINITION
There are no validation results if theSPARQL-based constraint hastrue as avalue for the propertysh:deactivated. Otherwise, execute the SPARQL query specified by theSPARQL-based constraint$sparqlpre-binding the variablesthis and, if supported,shapesGraph andcurrentShape as described in5.3.1Pre-bound Variables in SPARQL Constraints ($this, $shapesGraph, $currentShape). If theshape is aproperty shape, then prior to executionsubstitute the variablePATH where it appears in thepredicate position of atriple pattern with a valid SPARQL surface syntax string of theSHACL property path specified viash:path at theproperty shape.There is one validation result for eachsolution that does not havetrue as thebinding for the variablefailure.These validation resultsMUST have the property values explained in5.3.2Mapping of Solution Bindings to Result Properties. AfailureMUST be produced if and only if one of thesolutions hastrue as thebinding forfailure.

5.3.1Pre-bound Variables in SPARQL Constraints ($this, $shapesGraph, $currentShape)

When the SPARQL queries ofSPARQL-based constraints and thevalidators ofSPARQL-based constraint components areprocessed, the SHACL-SPARQL processorpre-binds values for the variables in the following table.

VariableInterpretation
this Thefocus node.
shapesGraph (Optional) Can be used to query the shapes graph as inGRAPH $shapesGraph { ... }. If the shapes graph is a named graph in the same dataset as the data graph then it is theIRI of the shapes graph in the dataset. Not all SHACL-SPARQL processors need to support this variable. Processors that do not support the variableshapesGraphMUST report afailure if they encounter a query that references this variable. Use ofGRAPH $shapesGraph { ... } should be handled with extreme caution. It may result in constraints that are not interoperable across different SHACL-SPARQL processors and that may not run on remote RDF datasets.
currentShape (Optional) The currentshape. Typically used in conjunction with the variableshapesGraph. The same support policies as forshapesGraph apply for this variable.

5.3.2Mapping of Solution Bindings to Result Properties

The propertyvalues of the validation result nodes are derived by the following rules, through a combination of result solutions and the values of the constraint itself. The rules are meant to be executed from top to bottom, so that the first bound value will be used.

PropertyProduction Rules
sh:focusNode
  1. The binding for the variablethis
sh:resultPath
  1. The binding for the variablepath, if that is aIRI
  2. For results produced by aproperty shape, aSHACL property path that is equivalent to thevalue ofsh:path of the shape
sh:value
  1. The binding for the variablevalue
  2. Thevalue node
sh:resultMessage
  1. The binding for the variablemessage
  2. For SPARQL-based constraints: The values ofsh:message of theSPARQL-based constraint. For SPARQL-based constraint components: The values ofsh:message of thevalidator of theSPARQL-based constraint component.
  3. For SPARQL-based constraint components: The values ofsh:message of theSPARQL-based constraint component.
These message literals may include the names of any SELECT result variables via{?varName} or{$varName}. If the constraint is based on aSPARQL-based constraint component, then the component'sparameter names can also be used. These{?varName} and{$varName} blocksSHOULD be replaced with suitable string representations of the values of said variables.
sh:sourceConstraint
  1. TheSPARQL-based constraint, i.e. the value ofsh:sparql

6.SPARQL-based Constraint Components

SPARQL-based constraints provide a lot of flexibility but may be hard to understand for some people or lead to repetition. This section introducesSPARQL-based constraint components as a way to abstract the complexity of SPARQL and to declare high-level reusable components similar to theCore constraint components. Such constraint components can be declared using the SHACL RDF vocabulary and thus shared and reused.

6.1An Example SPARQL-based Constraint Component

This section is non-normative.

The following example demonstrates how SPARQL can be used to specify new constraint components using the SHACL-SPARQL language. The example implementssh:pattern andsh:flags using aSPARQL ASK query to validate that eachvalue node matches a given regular expression. Note that this is only an example implementation and should not be considered normative.

sh:PatternConstraintComponenta sh:ConstraintComponent ;sh:parameter [sh:path sh:pattern ;] ;sh:parameter [sh:path sh:flags ;sh:optional true ;] ;sh:validator shimpl:hasPattern .shimpl:hasPatterna sh:SPARQLAskValidator ;sh:message "Value does not match pattern {$pattern}" ;sh:ask """ASK { FILTER (!isBlank($value) && IF(bound($flags), regex(str($value), $pattern, $flags), regex(str($value), $pattern)))}""" .

Constraint components provide instructions to validation engines on how to identify and validateconstraints within ashape. In general, if ashapeS has avalue for a propertyp, and there is aconstraint componentC that specifiesp as a parameter, andS has values for allmandatory parameters ofC, then the set of these parameter values (including theoptional parameters) declare aconstraint and the validation engine uses a suitablevalidator fromC to perform the validation of this constraint. In the example above,sh:PatternConstraintComponent declares the mandatory parametersh:pattern, the optional parametersh:flags, and avalidator that can be used to perform validation against eithernode shapes orproperty shapes.

6.2Syntax of SPARQL-based Constraint Components

ASPARQL-based constraint component is anIRI that hasSHACL typesh:ConstraintComponent in theshapes graph.

The mechanism to declare newconstraint components in this document is limited to those based on SPARQL. However, then general syntax of declaring parameters and validators has been designed to also work for other extension languages such as JavaScript.

6.2.1Parameter Declarations (sh:parameter)

Theparameters of aconstraint component are declared via the propertysh:parameter. The values ofsh:parameter are calledparameter declarations. The classsh:Parameter may be used astype ofparameter declarations but no such triple is required.Eachparameter declaration has exactly one value for the propertysh:path.Atparameter declarations, thevalue ofsh:path is anIRI.

Thelocal name of anIRI is defined as the longestNCNAME at the end of theIRI, not immediately preceded by the first colon in theIRI. Theparameter name of aparameter declaration is defined as thelocal name of thevalue ofsh:path. To ensure that a correct mapping from parameters into SPARQL variables is possible, the following syntax rules apply:

Everyparameter name is a validSPARQL VARNAME.Parameter names must not be one of the following:this,shapesGraph,currentShape,path,PATH,value.A constraint component where two or moreparameter declarations use the sameparameter names isill-formed.

The values ofsh:optional must be literals with datatypexsd:boolean.Aparameter declaration can have at most one value for the propertysh:optional. If set totrue then the parameter declaration declares anoptional parameter.Everyconstraint component has at least one non-optional parameter.

The classsh:Parameter is defined as aSHACL subclass ofsh:PropertyShape, and all properties that are applicable to property shapes may also be used for parameters. This includes descriptive properties such assh:name andsh:description but also constraint parameters such assh:class.Shapes that do notconform with the constraints declared for the parameters areill-formed. Some implementationsMAY use these constraint parameters to prevent the execution of constraint components with invalid parameter values.

6.2.2Label Templates (sh:labelTemplate)

The propertysh:labelTemplate can be used at anyconstraint component to suggest howconstraints could be rendered to humans.The values ofsh:labelTemplate are strings (possibly with language tag) and are calledlabel templates.

The remainder of this section is informative.

Label templates can include the names of the parameters that are declared for the constraint component using the syntaxes{?varName} or{$varName}, wherevarName is the name of theparameter name. At display time, these{?varName} and{$varName} blocksSHOULD be replaced with the actual parameter values. There may be multiple label templates for the same subject, but they should not have the same language tags.

6.2.3Validators

For every supported shape type (i.e.,property shape ornode shape) the constraint component declares a suitablevalidator. For a given constraint, a validator is selected from the constraint component using the following rules, in order:

  1. Fornode shapes, use one of the values ofsh:nodeValidator, if present.
  2. Forproperty shapes, use one of the values ofsh:propertyValidator, if present.
  3. Otherwise, use one of the values ofsh:validator.

If no suitable validator can be found, a SHACL-SPARQL processor ignores the constraint.

SHACL-SPARQL includes two types of validators, based onSPARQL SELECT (forsh:nodeValidator andsh:propertyValidator) orSPARQL ASK queries (forsh:validator).

6.2.3.1SELECT-based Validators

Validators withSHACL typesh:SPARQLSelectValidator are calledSELECT-based validators.The values ofsh:nodeValidator must beSELECT-based validators.The values ofsh:propertyValidator must beSELECT-based validators.SELECT-based validators have exactly onevalue for the propertysh:select. The value ofsh:select is a valid SPARQL SELECT query using the aforementionedprefix handling rules. The SPARQL query derived from the value ofsh:selectprojects the variablethis in its SELECT clause.

The remainder of this section is informative.

The following example illustrates the declaration of a constraint component based on a SPARQL SELECT query. It is a generalized variation of the example from5.1An Example SPARQL-based Constraint. That SPARQL query included two constants: the specific propertyex:germanLabel and the language tagde. Constraint components make it possible to generalize such scenarios, so that constants getpre-bound withparameters. This allows the query logic to be reused in multiple places, without having to write any new SPARQL.

ex:LanguageConstraintComponentUsingSELECTa sh:ConstraintComponent ;rdfs:label "Language constraint component" ;sh:parameter [sh:path ex:lang ;sh:datatype xsd:string ;sh:minLength 2 ;sh:name "language" ;sh:description "The language tag, e.g. \"de\"." ;] ;sh:labelTemplate "Values are literals with language \"{$lang}\"" ;sh:propertyValidator [a sh:SPARQLSelectValidator ;sh:message "Values are literals with language \"{?lang}\"" ;sh:select """SELECT DISTINCT $this ?valueWHERE {$this $PATH ?value .FILTER (!isLiteral(?value) || !langMatches(lang(?value), $lang))}"""] .

Once a constraint component has been declared (in ashapes graph), its parameters can be used as illustrated in the following example.

ex:LanguageExampleShapea sh:NodeShape ;sh:targetClass ex:Country ;sh:property [sh:path ex:germanLabel ;ex:lang "de" ;] ;sh:property [sh:path ex:englishLabel ;ex:lang "en" ;] .

The example shape above specifies the condition that all values ofex:germanLabel carry the language tagde while all values ofex:englishLabel haveen as their language. These details are specified via two property shapes that have values for theex:lang parameter required by the constraint component.

6.2.3.2ASK-based Validators

Many constraint components are of the form in which allvalue nodes are tested individually against some boolean condition. Writing SELECT queries for these becomes burdensome, especially if a constraint component can be used for bothproperty shapes andnode shapes. SHACL-SPARQL provides an alternative, more compact syntax for validators based on ASK queries.

Validators withSHACL typesh:SPARQLAskValidator are calledASK-based validators.The values ofsh:validator must beASK-based validators.ASK-based validators have exactly one value for the propertysh:ask.The value ofsh:ask must be a literal with datatypexsd:string.The value ofsh:ask must be a valid SPARQL ASK query using the aforementionedprefix handling rules.

The remainder of this section is informative.

The ASK queries returntrue if and only if a givenvalue node (represented by the pre-bound variablevalue) conforms to the constraint.

The following example declares a constraint component using an ASK query.

ex:LanguageConstraintComponentUsingASKa sh:ConstraintComponent ;rdfs:label "Language constraint component" ;sh:parameter [sh:path ex:lang ;sh:datatype xsd:string ;sh:minLength 2 ;sh:name "language" ;sh:description "The language tag, e.g. \"de\"." ;] ;sh:labelTemplate "Values are literals with language \"{$lang}\"" ;sh:validator ex:hasLang .ex:hasLanga sh:SPARQLAskValidator ;sh:message "Values are literals with language \"{$lang}\"" ;sh:ask """ASK {FILTER (isLiteral($value) && langMatches(lang($value), $lang))}""" .

Note that the validation condition implemented by an ASK query is "in the inverse direction" from its SELECT counterpart: ASK queries returntrue for value nodes that conform to the constraint, while SELECT queries return those value nodes that do not conform.

6.3Validation with SPARQL-based Constraint Components

This section defines thevalidator ofSPARQL-based constraint components. Note that this validator only explains one possible implementation strategy, and SHACL processors may choose alternative approaches as long as the outcome is equivalent.

As the first step, avalidatorMUST be selected based on the rules outlined in6.2.3Validators. Then the following rules apply, producing a set ofsolutions of SPARQL queries:

The SPARQL query executions aboveMUSTpre-bind the variablesthis and, if supported,shapesGraph andcurrentShape as described in5.3.1Pre-bound Variables in SPARQL Constraints ($this, $shapesGraph, $currentShape). In addition, eachvalue of aparameter of theconstraint component in theconstraintMUST bepre-bound as a variable that has theparameter name as its name.

The production rules for the validation results are identical to those forSPARQL-based constraints, using thesolutionsQS as produced above.

Appendix

A.Pre-binding of Variables in SPARQL Queries

Some features of SHACL-SPARQL rely on the concept ofpre-binding of variables as defined in this section.

The definition of pre-binding used by SHACL requires the following restrictions on SPARQL queries. SHACL-SPARQL processorsMUST report afailure when it is operating on ashapes graph that contains SHACL-SPARQL queries (viash:select andsh:ask) that violate any of these restrictions. Note that the termpotentially pre-bound variables includes the variablesthis,shapesGraph,currentShape,value (for ASK queries), and any variables that represent theparameters of theconstraint component that uses the query.

DEFINITION:Values Insertion

For solution mappingμ, defineTable(μ) to be the multiset formed fromμ.

   Table(μ) = { μ }
   Card[μ] = 1

Define theValues Insertion functionReplace(X, μ) to replace each occurenceY of aBasic Graph Pattern,Property Path Expression,Graph(Var, pattern) inX withjoin(Y, Table(μ)).

DEFINITION:Pre-binding of variables

The evaluation of theSPARQL QueryQ = (E, DS, QF) withpre-bound variablesμ is defined as the evaluation of SPARQL queryQ' = (Replace(E, μ), DS, QF).

B.Summary of SHACL Syntax Rules

This section enumerates all normative syntax rules of SHACL. This section is automatically generated from other parts of this spec and hyperlinks are provided back into the prose if the context of the rule in unclear. Nodes that violate these rules in ashapes graph areill-formed.

Syntax Rule IdSyntax Rule Text
SHACL-listASHACL list in an RDF graphG is anIRI or ablank node that is eitherrdf:nil (provided thatrdf:nil has novalue for eitherrdf:first orrdf:rest), or has exactly onevalue for the propertyrdf:first inG and exactly onevalue for the propertyrdf:rest inG that is also a SHACL list inG, and the list does not have itself as a value of the property pathrdf:rest+ inG.
entailment-nodeKindThevalues of the propertysh:entailment are IRIs.
shape Ashape is anIRI orblank nodes that fulfills at least one of the following conditions in theshapes graph:
multiple-parameters Some constraint components such assh:PatternConstraintComponent declare more than one parameter. Shapes that have more than one value for any of the parameters of such components areill-formed.
targetNode-nodeKindEachvalue ofsh:targetNode in a shape is either anIRI or aliteral.
targetClass-nodeKindEach value ofsh:targetClass in a shape is anIRI.
implicit-targetClass-nodeKind Ifs is aSHACL instance ofsh:NodeShape orsh:PropertyShape in an RDF graphG ands is also aSHACL instance ofrdfs:Class inG ands is not anIRI thens is anill-formed shape inG.
targetSubjectsOf-nodeKindThevalues ofsh:targetSubjectsOf in a shape areIRIs.
targetObjectsOf-nodeKindThevalues ofsh:targetObjectsOf in a shape areIRIs.
severity-maxCountShapes can specify onevalue for the propertysh:severity in theshapes graph.
severity-nodeKindEach value ofsh:severity in a shape is anIRI.
message-datatypeThe values ofsh:message in a shape are eitherxsd:string literals or literals with a language tag.
deactivated-maxCountShapes can have at most one value for the propertysh:deactivated.
deactivated-datatypeThe value ofsh:deactivated in a shape must be eithertrue orfalse.
NodeShape-path-maxCountSHACL instances ofsh:NodeShape cannot have avalue for the propertysh:path.
PropertyShapeAproperty shape is ashape in theshapes graph that is thesubject of atriple that hassh:path as itspredicate.
path-maxCountA shape has at most onevalue forsh:path.
path-nodeEachvalue ofsh:path in a shape must be awell-formedSHACL property path.
PropertyShape-path-minCountSHACL instances ofsh:PropertyShape have onevalue for the propertysh:path.
path-metaruleA node in an RDF graph is awell-formedSHACL property pathp if it satisfies exactly one of the syntax rules in the following sub-sections.
path-non-recursiveA nodep is not awell-formed SHACL property path ifp is a blank node and any path mappings ofp directly or transitively referencep.
path-sequence Asequence path is ablank node that is aSHACL list with at least twomembers and each member is awell-formed SHACL property path.
path-alternative Analternative path is ablank node that is the subject of exactly one triple inG. This triple hassh:alternativePath as predicate,L as object, andL is aSHACL list with at least twomembers and each member ofL is awell-formed SHACL property path.
path-inverse Aninverse path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:inversePath as predicate, and theobjectv is awell-formed SHACL property path.
path-zero-or-more Azero-or-more path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:zeroOrMorePath aspredicate, and theobjectv is awell-formed SHACL property path.
path-one-or-more Aone-or-more path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:oneOrMorePath aspredicate, and theobjectv is awell-formed SHACL property path.
path-zero-or-one Azero-or-one path is ablank node that is thesubject of exactly onetriple inG. This triple hassh:zeroOrOnePath aspredicate, and theobjectv is awell-formed SHACL property path.
shapesGraph-nodeKindEveryvalue ofsh:shapesGraph is anIRI
class-nodeKindThe values ofsh:class in a shape are IRIs.
datatype-nodeKindThe values ofsh:datatype in a shape areIRIs.
datatype-maxCountA shape has at most one value forsh:datatype.
nodeKind-inThe values ofsh:nodeKind in a shape are one of the following six instances of the classsh:NodeKind:sh:BlankNode,sh:IRI,sh:Literalsh:BlankNodeOrIRI,sh:BlankNodeOrLiteral andsh:IRIOrLiteral.
nodeKind-maxCountA shape has at most one value forsh:nodeKind.
minCount-scopeNode shapes cannot have any value forsh:minCount.
minCount-maxCountAproperty shape has at most one value forsh:minCount.
minCount-datatypeThe values ofsh:minCount in a property shape are literals with datatypexsd:integer.
maxCount-scopeNode shapes cannot have any value forsh:maxCount.
maxCount-maxCountAproperty shape has at most one value forsh:maxCount.
maxCount-datatypeThe values ofsh:maxCount in a property shape are literals with datatypexsd:integer.
minExclusive-nodeKindThe values ofsh:minExclusive in a shape areliterals.
minExclusive-maxCountA shape has at most one value forsh:minExclusive.
minInclusive-nodeKindThe values ofsh:minInclusive in a shape areliterals.
minInclusive-maxCountA shape has at most one value forsh:minInclusive.
maxExclusive-nodeKindThe values ofsh:maxExclusive in a shape areliterals.
maxExclusive-maxCountA shape has at most one value forsh:maxExclusive.
maxInclusive-nodeKindThe values ofsh:maxInclusive in a shape areliterals.
maxInclusive-maxCountA shape has at most one value forsh:maxInclusive.
minLength-datatypeThe values ofsh:minLength in a shape are literals with datatypexsd:integer.
minLength-maxCountA shape has at most one value forsh:minLength.
maxLength-datatypeThe values ofsh:maxLength in a shape are literals with datatypexsd:integer.
maxLength-maxCountA shape has at most one value forsh:maxLength.
pattern-datatypeThe values ofsh:pattern in a shape are literals with datatypexsd:string.
pattern-regexThe values ofsh:pattern in a shape are valid pattern arguments for theSPARQL REGEX function.
flags-datatypeThe values ofsh:flags in a shape are literals with datatypexsd:string.
languageIn-nodeEach value ofsh:languageIn in a shape is aSHACL list.
languageIn-members-datatypeEachmember of such a list is a literal with datatypexsd:string.
languageIn-maxCountA shape has at most one value forsh:languageIn.
uniqueLang-datatypeThe values ofsh:uniqueLang in a shape are literals with datatypexsd:boolean.
uniqueLang-maxCountA property shape has at most one value forsh:uniqueLang.
uniqueLang-scopeNode shapes cannot have any value forsh:uniqueLang.
equals-nodeKindThe values ofsh:equals in a shape areIRIs.
disjoint-nodeKindThe values ofsh:disjoint in a shape areIRIs.
lessThan-nodeKindThe values ofsh:lessThan in a shape areIRIs.
lessThan-scopeNode shapes cannot have any value forsh:lessThan.
lessThanOrEquals-nodeKindThe values ofsh:lessThanOrEquals in a shape areIRIs.
lessThanOrEquals-scopeNode shapes cannot have any value forsh:lessThanOrEquals.
not-nodeThe values ofsh:not in a shape must bewell-formedshapes.
and-nodeEach value ofsh:and in a shape is aSHACL list.
and-members-nodeEachmember of such list must be awell-formedshape.
or-nodeEach value ofsh:or in a shape is aSHACL list.
or-members-nodeEachmember of such list must be awell-formedshape.
xone-nodeEach value ofsh:xone in a shape is aSHACL list.
xone-members-nodeEachmember of such list must be awell-formedshape.
node-nodeThe values ofsh:node in a shape must bewell-formednode shapes.
property-nodeEach value ofsh:property in a shape must be awell-formedproperty shape.
qualifiedValueShape-nodeThe values ofsh:qualifiedValueShape in a shape must bewell-formedshapes.
qualifiedValueShape-scopeNode shapes cannot have any value forsh:qualifiedValueShape.
qualifiedValueShapesDisjoint-datatypeThe values ofsh:qualifiedValueShapesDisjoint in a shape are literals with datatypexsd:boolean.
qualifiedMinCount-datatypeThe values ofsh:qualifiedMinCount in a shape are literals with datatypexsd:integer.
qualifiedMaxCount-datatypeThe values ofsh:qualifiedMaxCount in a shape are literals with datatypexsd:integer.
closed-datatypeThe values ofsh:closed in a shape are literals with datatypexsd:boolean.
ignoredProperties-nodeThe values ofsh:ignoredProperties in a shape must beSHACL lists.
ignoredProperties-members-nodeKindEachmember of such a list must be aIRI.
in-nodeEach value ofsh:in in a shape is aSHACL list.
in-maxCountA shape has at most one value forsh:in.
sparql-nodeKindShapes may have values for the propertysh:sparql, and these values are eitherIRIs orblank nodes.
SPARQLConstraint-select-countSPARQL-based constraints have exactly onevalue for the propertysh:select
SPARQLConstraint-select-datatypeThe value ofsh:select is aliteral of datatypexsd:string.
select-query-validUsing theprefix handling rules, the value ofsh:select is a valid SPARQL 1.1 SELECT query.
select-query-thisThe SPARQL query derived from the value ofsh:selectprojects the variablethis in the SELECT clause.
SPARQLConstraint-message-datatypeSPARQL-based constraints may have values for the propertysh:message and these are eitherxsd:string literals or literals with a language tag.
SPARQLConstraint-deactivated-maxCountSPARQL-based constraints may have at most one value for the propertysh:deactivated
PATH-positionThe only legal use of the variablePATH in the SPARQL queries ofSPARQL-based constraints andSELECT-based validators is in thepredicate position of atriple pattern.
declare-nodeKindThevalues of the propertysh:declare areIRIs orblank nodes
prefix-countPrefix declarations have exactly one value for the propertysh:prefix
prefix-datatypeThe values ofsh:prefix areliterals of datatypexsd:string.
namespace-countPrefix declarations have exactly one value for the propertysh:namespace.
namespace-datatypeThe values ofsh:namespace areliterals of datatypexsd:anyURI.
prefixes-nodeKindThe values ofsh:prefixes are eitherIRIs orblank nodes.
prefixes-duplicatesA SHACL processor collects a set of prefix mappings as the union of all individual prefix mappings that arevalues of theSPARQL property pathsh:prefixes/owl:imports*/sh:declare of theSPARQL-based constraint orvalidator. If such a collection of prefix declarations contains multiple namespaces for the samevalue ofsh:prefix, then theshapes graph isill-formed.
ConstraintComponentASPARQL-based constraint component is anIRI that hasSHACL typesh:ConstraintComponent in theshapes graph.
Parameter-predicate-countEachparameter declaration has exactly one value for the propertysh:path
ParameterAtparameter declarations, thevalue ofsh:path is anIRI.
parameter-name-VARNAMEEveryparameter name is a validSPARQL VARNAME.
parameter-name-not-inParameter names must not be one of the following:this,shapesGraph,currentShape,path,PATH,value.
parameter-name-uniqueA constraint component where two or moreparameter declarations use the sameparameter names isill-formed.
optional-datatypeThe values ofsh:optional must be literals with datatypexsd:boolean.
optional-maxCountAparameter declaration can have at most one value for the propertysh:optional.
ConstraintComponent-parameterEveryconstraint component has at least one non-optional parameter.
Parameter-conformanceShapes that do notconform with the constraints declared for the parameters areill-formed.
labelTemplate-datatypeThe values ofsh:labelTemplate are strings (possibly with language tag)
nodeValidator-classThe values ofsh:nodeValidator must beSELECT-based validators.
propertyValidator-classThe values ofsh:propertyValidator must beSELECT-based validators.
SPARQLSelectValidator-select-countSELECT-based validators have exactly onevalue for the propertysh:select.
validator-classThe values ofsh:validator must beASK-based validators.
ask-countASK-based validators have exactly one value for the propertysh:ask
ask-datatypeThe value ofsh:ask must be a literal with datatypexsd:string.
ask-sparqlThe value ofsh:ask must be a valid SPARQL ASK query using the aforementionedprefix handling rules.
pre-binding-limitations

The definition of pre-binding used by SHACL requires the following restrictions on SPARQL queries. SHACL-SPARQL processorsMUST report afailure when it is operating on ashapes graph that contains SHACL-SPARQL queries (viash:select andsh:ask) that violate any of these restrictions. Note that the termpotentially pre-bound variables includes the variablesthis,shapesGraph,currentShape,value (for ASK queries), and any variables that represent theparameters of theconstraint component that uses the query.

  • SPARQL queries must not contain aMINUS clause
  • SPARQL queries must not contain a federated query (SERVICE)
  • SPARQL queries must not contain aVALUES clause
  • SPARQL queries must not use the syntax form ​​AS ?var for any potentially pre-bound variable
  • Subqueries must return all potentially pre-bound variables, exceptshapesGraph andcurrentShape which are optional as already mentioned in5.3.1Pre-bound Variables in SPARQL Constraints ($this, $shapesGraph, $currentShape)

C.SHACL Shapes to Validate Shapes Graphs

The following shapes graph is intended to enforce many of the syntactic constraints related to SHACL Core in this specification. As such, it can be understood as a machine-readable version of a subset of those constraints, and should be understood as normative. If differences are found between the constraints expressed here and elsewhere in this specification, that indicates an error in the following shapes graph. Please see theErrata Page for an enumeration and analysis of possible errors that have been reported. This shapes graph is available athttp://www.w3.org/ns/shacl-shacl. That version may be more up-to-date than this specification as errata are noted against this specification.

@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@prefix sh:   <http://www.w3.org/ns/shacl#> .@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .@prefix shsh: <http://www.w3.org/ns/shacl-shacl#> .shsh:rdfs:label "SHACL for SHACL"@en ;rdfs:comment "This shapes graph can be used to validate SHACL shapes graphs against a subset of the SHACL syntax rules."@en ;sh:declare [sh:prefix "shsh" ;sh:namespace "http://www.w3.org/ns/shacl-shacl#" ;] .shsh:ListShapea sh:NodeShape ;rdfs:label "List shape"@en ;rdfs:comment "A shape describing well-formed RDF lists. Currently does not check for non-recursion. This could be expressed using SHACL-SPARQL."@en ;rdfs:seeAlso <https://www.w3.org/TR/shacl/#syntax-rule-SHACL-list> ;sh:property [sh:path [ sh:zeroOrMorePath rdf:rest ] ;rdfs:comment "Each list member (including this node) must be have the shape shsh:ListNodeShape."@en ;sh:hasValue rdf:nil ;sh:node shsh:ListNodeShape ;] .shsh:ListNodeShapea sh:NodeShape ;rdfs:label "List node shape"@en ;rdfs:comment "Defines constraints on what it means for a node to be a node within a well-formed RDF list. Note that this does not check whether the rdf:rest items are also well-formed lists as this would lead to unsupported recursion."@en ;sh:or ( [sh:hasValue rdf:nil ;        sh:property [sh:path rdf:first ;sh:maxCount 0 ;] ;sh:property [sh:path rdf:rest ;sh:maxCount 0 ;] ;][sh:not [ sh:hasValue rdf:nil ] ;sh:property [sh:path rdf:first ;sh:maxCount 1 ;sh:minCount 1 ;] ;sh:property [sh:path rdf:rest ;sh:maxCount 1 ;sh:minCount 1 ;] ;] ) .shsh:ShapeShapea sh:NodeShape ;rdfs:label "Shape shape"@en ;rdfs:comment "A shape that can be used to validate syntax rules for other shapes."@en ;# See https://www.w3.org/TR/shacl/#shapes for what counts as a shapesh:targetClass sh:NodeShape ;sh:targetClass sh:PropertyShape ;sh:targetSubjectsOf sh:targetClass, sh:targetNode, sh:targetObjectsOf, sh:targetSubjectsOf ;sh:targetSubjectsOf sh:and, sh:class, sh:closed, sh:datatype, sh:disjoint, sh:equals, sh:flags, sh:hasValue,sh:ignoredProperties, sh:in, sh:languageIn, sh:lessThan, sh:lessThanOrEquals, sh:maxCount, sh:maxExclusive,sh:maxInclusive, sh:maxLength, sh:minCount, sh:minExclusive, sh:minInclusive, sh:minLength, sh:node, sh:nodeKind,sh:not, sh:or, sh:pattern, sh:property, sh:qualifiedMaxCount, sh:qualifiedMinCount, sh:qualifiedValueShape,sh:qualifiedValueShape, sh:qualifiedValueShapesDisjoint, sh:qualifiedValueShapesDisjoint, sh:uniqueLang, sh:xone ;sh:targetObjectsOf sh:node ;# node-nodesh:targetObjectsOf sh:not ;# not-nodesh:targetObjectsOf sh:property ;# property-nodesh:targetObjectsOf sh:qualifiedValueShape ;# qualifiedValueShape-node# Shapes are either node shapes or property shapessh:xone ( shsh:NodeShapeShape shsh:PropertyShapeShape ) ;sh:property [sh:path sh:targetNode ;sh:nodeKindsh:IRIOrLiteral ;# targetNode-nodeKind] ; sh:property [sh:path sh:targetClass ;sh:nodeKind sh:IRI ;# targetClass-nodeKind] ;sh:property [sh:path sh:targetSubjectsOf ;sh:nodeKind sh:IRI ;# targetSubjectsOf-nodeKind] ;sh:property [sh:path sh:targetObjectsOf ;sh:nodeKind sh:IRI ;# targetObjectsOf-nodeKind] ;sh:or ( [ sh:not [ sh:class rdfs:Class ; sh:or ( [ sh:class sh:NodeShape ] [ sh:class sh:PropertyShape ] )] ][ sh:nodeKind sh:IRI ]  ) ;# implicit-targetClass-nodeKindsh:property [sh:path sh:severity ;sh:maxCount 1 ;# severity-maxCountsh:nodeKind sh:IRI ;# severity-nodeKind] ;sh:property [sh:path sh:message ;sh:or ( [ sh:datatype xsd:string ] [ sh:datatype rdf:langString ] ) ;# message-datatype] ;sh:property [sh:path sh:deactivated ;sh:maxCount 1 ;# deactivated-maxCountsh:in ( true false ) ;# deactivated-datatype] ;sh:property [sh:path sh:and ;sh:node shsh:ListShape ;# and-node] ;sh:property [sh:path sh:class ;sh:nodeKind sh:IRI ;# class-nodeKind] ;sh:property [sh:path sh:closed ;sh:datatype xsd:boolean ;# closed-datatypesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:ignoredProperties ;sh:node shsh:ListShape ;# ignoredProperties-nodesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path ( sh:ignoredProperties [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ;sh:nodeKind sh:IRI ;# ignoredProperties-members-nodeKind] ;sh:property [sh:path sh:datatype ;sh:nodeKind sh:IRI ;# datatype-nodeKindsh:maxCount 1 ;# datatype-maxCount] ;sh:property [sh:path sh:disjoint ;sh:nodeKind sh:IRI ;# disjoint-nodeKind] ;sh:property [sh:path sh:equals ;sh:nodeKind sh:IRI ;# equals-nodeKind] ;sh:property [sh:path sh:in ;sh:maxCount 1 ;# in-maxCountsh:node shsh:ListShape ;# in-node] ;sh:property [sh:path sh:languageIn ;sh:maxCount 1 ;# languageIn-maxCountsh:node shsh:ListShape ;# languageIn-node] ;sh:property [sh:path ( sh:languageIn [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ;sh:datatype xsd:string ;# languageIn-members-datatype] ;sh:property [sh:path sh:lessThan ;sh:nodeKind sh:IRI ;# lessThan-nodeKind] ;sh:property [sh:path sh:lessThanOrEquals ;sh:nodeKind sh:IRI ;# lessThanOrEquals-nodeKind] ;sh:property [sh:path sh:maxCount ;sh:datatype xsd:integer ;# maxCount-datatypesh:maxCount 1 ;# maxCount-maxCount] ;sh:property [sh:path sh:maxExclusive ;sh:maxCount 1 ;# maxExclusive-maxCountsh:nodeKind sh:Literal ;# maxExclusive-nodeKind] ;sh:property [sh:path sh:maxInclusive ;sh:maxCount 1 ;# maxInclusive-maxCountsh:nodeKind sh:Literal ;# maxInclusive-nodeKind] ;sh:property [sh:path sh:maxLength ;sh:datatype xsd:integer ;# maxLength-datatypesh:maxCount 1 ;# maxLength-maxCount] ;sh:property [sh:path sh:minCount ;sh:datatype xsd:integer ;# minCount-datatypesh:maxCount 1 ;# minCount-maxCount] ;sh:property [sh:path sh:minExclusive ;sh:maxCount 1 ;# minExclusive-maxCountsh:nodeKind sh:Literal ;# minExclusive-nodeKind] ;sh:property [sh:path sh:minInclusive ;sh:maxCount 1 ;# minInclusive-maxCountsh:nodeKind sh:Literal ;# minInclusive-nodeKind] ;sh:property [sh:path sh:minLength ;sh:datatype xsd:integer ;# minLength-datatypesh:maxCount 1 ;# minLength-maxCount] ;sh:property [sh:path sh:nodeKind ;sh:in ( sh:BlankNode sh:IRI sh:Literal sh:BlankNodeOrIRI sh:BlankNodeOrLiteral sh:IRIOrLiteral ) ;# nodeKind-insh:maxCount 1 ;# nodeKind-maxCount] ;sh:property [sh:path sh:or ;sh:node shsh:ListShape ;# or-node] ;sh:property [sh:path sh:pattern ;sh:datatype xsd:string ;# pattern-datatypesh:maxCount 1 ;# multiple-parameters# Not implemented: syntax rule pattern-regex] ;sh:property [sh:path sh:flags ;sh:datatype xsd:string ;# flags-datatypesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:qualifiedMaxCount ;sh:datatype xsd:integer ;# qualifiedMaxCount-datatypesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:qualifiedMinCount ;sh:datatype xsd:integer ;# qualifiedMinCount-datatypesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:qualifiedValueShape ;sh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:qualifiedValueShapesDisjoint ;sh:datatype xsd:boolean ;# qualifiedValueShapesDisjoint-datatypesh:maxCount 1 ;# multiple-parameters] ;sh:property [sh:path sh:uniqueLang ;sh:datatype xsd:boolean ;# uniqueLang-datatypesh:maxCount 1 ;# uniqueLang-maxCount] ;sh:property [sh:path sh:xone ;sh:node shsh:ListShape ;# xone-node] .shsh:NodeShapeShapea sh:NodeShape ;sh:targetObjectsOf sh:node ;# node-nodesh:property [sh:path sh:path ;sh:maxCount 0 ;# NodeShape-path-maxCount] ;sh:property [sh:path sh:lessThan ;sh:maxCount 0 ;# lessThan-scope] ;sh:property [sh:path sh:lessThanOrEquals ;sh:maxCount 0 ;# lessThanOrEquals-scope] ;sh:property [sh:path sh:maxCount ;sh:maxCount 0 ;# maxCount-scope] ;sh:property [sh:path sh:minCount ;sh:maxCount 0 ;# minCount-scope] ;sh:property [sh:path sh:qualifiedValueShape ;sh:maxCount 0 ;# qualifiedValueShape-scope] ;sh:property [sh:path sh:uniqueLang ;sh:maxCount 0 ;# uniqueLang-scope] .shsh:PropertyShapeShapea sh:NodeShape ;sh:targetObjectsOf sh:property ;# property-nodesh:property [sh:path sh:path ;sh:maxCount 1 ;# path-maxCountsh:minCount 1 ;# PropertyShape-path-minCountsh:node shsh:PathShape ;# path-node] .# Values of sh:and, sh:or and sh:xone must be lists of shapesshsh:ShapesListShapea sh:NodeShape ;sh:targetObjectsOf sh:and ;# and-members-nodesh:targetObjectsOf sh:or ;# or-members-nodesh:targetObjectsOf sh:xone ;# xone-members-nodesh:property [sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ;sh:node shsh:ShapeShape ;] .# A path of blank node path syntax, used to simulate recursion_:PathPathsh:alternativePath (( [ sh:zeroOrMorePath rdf:rest ] rdf:first )( sh:alternativePath [ sh:zeroOrMorePath rdf:rest ] rdf:first )sh:inversePathsh:zeroOrMorePathsh:oneOrMorePathsh:zeroOrOnePath ) .shsh:PathShapea sh:NodeShape ;rdfs:label "Path shape"@en ;rdfs:comment "A shape that can be used to validate the syntax rules of well-formed SHACL paths."@en ;rdfs:seeAlso <https://www.w3.org/TR/shacl/#property-paths> ;sh:property [sh:path [ sh:zeroOrMorePath _:PathPath ] ;sh:node shsh:PathNodeShape ;] .shsh:PathNodeShapesh:xone (# path-metarule[ sh:nodeKind sh:IRI ]          # 2.3.1.1: Predicate path[ sh:nodeKind sh:BlankNode ;    # 2.3.1.2: Sequence path  sh:node shsh:PathListWithAtLeast2Members ;][ sh:nodeKind sh:BlankNode ;    # 2.3.1.3: Alternative path  sh:closed true ;  sh:property [    sh:path sh:alternativePath ;    sh:node shsh:PathListWithAtLeast2Members ;    sh:minCount 1 ;    sh:maxCount 1 ;  ]][ sh:nodeKind sh:BlankNode ;    # 2.3.1.4: Inverse path  sh:closed true ;  sh:property [    sh:path sh:inversePath ;    sh:minCount 1 ;    sh:maxCount 1 ;  ] ][ sh:nodeKind sh:BlankNode ;    # 2.3.1.5: Zero-or-more path  sh:closed true ;  sh:property [    sh:path sh:zeroOrMorePath ;    sh:minCount 1 ;    sh:maxCount 1 ;  ] ][ sh:nodeKind sh:BlankNode ;    # 2.3.1.6: One-or-more path  sh:closed true ;  sh:property [    sh:path sh:oneOrMorePath ;    sh:minCount 1 ;    sh:maxCount 1 ;  ] ][ sh:nodeKind sh:BlankNode ;    # 2.3.1.7: Zero-or-one path  sh:closed true ;  sh:property [    sh:path sh:zeroOrOnePath ;    sh:minCount 1 ;    sh:maxCount 1 ;  ] ]) .shsh:PathListWithAtLeast2Membersa sh:NodeShape ;sh:node shsh:ListShape ;sh:property [sh:path [ sh:oneOrMorePath rdf:rest ] ;sh:minCount 2 ;    # 1 other list node plus rdf:nil] .shsh:ShapesGraphShapea sh:NodeShape ;sh:targetObjectsOf sh:shapesGraph ;sh:nodeKind sh:IRI .# shapesGraph-nodeKindshsh:EntailmentShapea sh:NodeShape ;sh:targetObjectsOf sh:entailment ;sh:nodeKind sh:IRI .# entailment-nodeKind

D.Summary of SHACL Core Validators

This section enumerates all normativevalidators of SHACL Core. This section is automatically generated from other parts of this spec and hyperlinks are provided back into the prose if the context of the validator in unclear.

Validators by Constraint Component
sh:ClassConstraintComponent: For eachvalue node that is either aliteral, or a non-literal that is not aSHACL instance of$class in thedata graph, there is avalidation result with thevalue node assh:value.
sh:DatatypeConstraintComponent: For eachvalue node that is not aliteral, or is aliteral with a datatype that does not match$datatype, there is avalidation result with thevalue node assh:value. The datatype of a literal is determined following thedatatype function of SPARQL 1.1. Aliteral matches a datatype if theliteral's datatype has the sameIRI and, for the datatypes supported by SPARQL 1.1, is not anill-typed literal.
sh:NodeKindConstraintComponent: For eachvalue node that does not match$nodeKind, there is avalidation result with thevalue node assh:value. AnyIRI matches onlysh:IRI,sh:BlankNodeOrIRI andsh:IRIOrLiteral. Anyblank node matches onlysh:BlankNode,sh:BlankNodeOrIRI andsh:BlankNodeOrLiteral. Anyliteral matches onlysh:Literal,sh:BlankNodeOrLiteral andsh:IRIOrLiteral.
sh:MinCountConstraintComponent: If the number ofvalue nodes is less than$minCount, there is avalidation result.
sh:MaxCountConstraintComponent: If the number ofvalue nodes is greater than$maxCount, there is avalidation result.
sh:MinExclusiveConstraintComponent: For eachvalue nodev where the SPARQL expression$minExclusive < v does not returntrue, there is avalidation result withv assh:value.
sh:MinInclusiveConstraintComponent: For eachvalue nodev where the SPARQL expression$minInclusive <= v does not returntrue, there is avalidation result withv assh:value.
sh:MaxExclusiveConstraintComponent: For eachvalue nodev where the SPARQL expression$maxExclusive > v does not returntrue, there is avalidation result withv assh:value.
sh:MaxInclusiveConstraintComponent: For eachvalue nodev where the SPARQL expression$maxInclusive >= v does not returntrue, there is avalidation result withv assh:value.
sh:MinLengthConstraintComponent: For eachvalue nodev where the length (as defined by theSPARQL STRLEN function) of the string representation ofv (as defined by theSPARQL str function) is less than$minLength, or wherev is ablank node, there is avalidation result withv assh:value.
sh:MaxLengthConstraintComponent: For eachvalue nodev where the length (as defined by theSPARQL STRLEN function) of the string representation ofv (as defined by theSPARQL str function) is greater than$maxLength, or wherev is ablank node, there is avalidation result withv assh:value.
sh:PatternConstraintComponent: For eachvalue node that is a blank node or where the string representation (as defined by theSPARQL str function) does not match the regular expression$pattern (as defined by theSPARQL REGEX function), there is avalidation result with thevalue node assh:value. If$flags has a value then the matchingMUST follow the definition of the 3-argument variant of the SPARQL REGEX function, using$flags as third argument.
sh:LanguageInConstraintComponent: For eachvalue node that is either not aliteral or that does not have a language tag matching any of the basic language ranges that are themembers of$languageIn following the filtering schema defined by theSPARQL langMatches function, there is avalidation result with thevalue node assh:value.
sh:UniqueLangConstraintComponent: If$uniqueLang istrue then for each non-empty language tag that is used by at least twovalue nodes, there is avalidation result.
sh:EqualsConstraintComponent: For eachvalue node that does not exist as avalue of the property$equals at thefocus node, there is avalidation result with thevalue node assh:value. For eachvalue of the property$equals at thefocus node that is not one of thevalue nodes, there is avalidation result with thevalue assh:value.
sh:DisjointConstraintComponent: For eachvalue node that also exists as avalue of the property$disjoint at thefocus node, there is avalidation result with thevalue node assh:value.
sh:LessThanConstraintComponent: For each pair ofvalue nodes and the values of the property$lessThan at the givenfocus node where the firstvalue is not less than the secondvalue (based on SPARQL's< operator) or where the two values cannot be compared, there is avalidation result with thevalue node assh:value.
sh:LessThanOrEqualsConstraintComponent: For each pair ofvalue nodes and the values of the property$lessThanOrEquals at the givenfocus node where the firstvalue is not less than or equal to the secondvalue (based on SPARQL's<= operator) or where the two values cannot be compared, there is avalidation result with thevalue node assh:value.
sh:NotConstraintComponent: For eachvalue nodev: AfailureMUST be reported if theconformance checking ofv against the shape$not produces afailure. Otherwise, ifvconforms to the shape$not, there isvalidation result withv assh:value.
sh:AndConstraintComponent: For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against any of themembers of$and produces afailure. Otherwise, ifv does notconform to eachmember of$and, there is avalidation result withv assh:value.
sh:OrConstraintComponent: For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against any of themembers produces afailure. Otherwise, ifvconforms to none of themembers of$or there is avalidation result withv assh:value.
sh:XoneConstraintComponent: For eachvalue nodev letN be the number of theshapes that aremembers of$xone wherevconforms to the shape. AfailureMUST be produced if theconformance checking ofv against any of themembers produces afailure. Otherwise, ifN is not exactly1, there is avalidation result withv assh:value.
sh:NodeConstraintComponent: For eachvalue nodev: AfailureMUST be produced if theconformance checking ofv against$node produces afailure. Otherwise, ifv does notconform to$node, there is avalidation result withv assh:value.
sh:PropertyConstraintComponent: For eachvalue nodev: AfailureMUST be produced if the validation ofv asfocus node against the property shape$property produces afailure. Otherwise, the validation results are the results ofvalidatingv asfocus node against the property shape$property.
sh:QualifiedMinCountConstraintComponent: LetC be the number ofvalue nodesv wherevconforms to$qualifiedValueShape and wherev does notconform to any of thesibling shapes for thecurrent shape, i.e. the shape thatv is validated against and which has$qualifiedValueShape as its value forsh:qualifiedValueShape. AfailureMUST be produced if any of the said conformance checks produces afailure. Otherwise, there is avalidation result ifC is less than$qualifiedMinCount. Theconstraint component forsh:qualifiedMinCount issh:QualifiedMinCountConstraintComponent.
sh:QualifiedMaxCountConstraintComponent: LetC be as defined forsh:qualifiedMinCount above. AfailureMUST be produced if any of the said conformance checks produces afailure. Otherwise, there is avalidation result ifC is greater than$qualifiedMaxCount. Theconstraint component forsh:qualifiedMaxCount issh:QualifiedMaxCountConstraintComponent.
sh:ClosedConstraintComponent: If$closed istrue then there is avalidation result for eachtriple that has avalue node as itssubject and apredicate that is not explicitly enumerated as avalue ofsh:path in any of theproperty shapes declared viash:property at the current shape. If$ignoredProperties has a value then the properties enumerated asmembers of thisSHACL list are also permitted for thevalue node. Thevalidation resultMUST have thepredicate of the triple as itssh:resultPath, and theobject of the triple as itssh:value.
sh:HasValueConstraintComponent: If the RDF term$hasValue is not among thevalue nodes, there is avalidation result.
sh:InConstraintComponent: For eachvalue node that is not amember of$in, there is avalidation result with thevalue node assh:value.

E.Security and Privacy Considerations

This section is non-normative.

Like most RDF-based technologies, SHACL processors may operate on graphs that are combined from various sources. Some applications may have an open "linked data" architecture and dynamically assemble RDF triples from sources that are outside of an organization's network of trust. Since RDF allows anyone to add statements about any resource, triples may modify the originally intended semantics of shape definitions or nodes in a data graph and thus lead to misleading results. Protection against this (and the following) scenario can be achieved by only using trusted and verified RDF sources and eliminating the possibility that graphs are dynamically added viaowl:imports andsh:shapesGraph.

SHACL-SPARQL includes all thesecurity issues of SPARQL.

F.Acknowledgements

This section is non-normative.

Many people contributed to this specification, including members of the RDF Data Shapes Working Group. We especially thank the following:

Arnaud Le Hors (chair until end of 2016), Dean Allemang, Jim Amsden, Iovka Boneva, Olivier Corby, Karen Coyle, Richard Cyganiak, Michel Dumontier, Sandro Hawke, Holger Knublauch, Dimitris Kontokostas, Jose Labra, Pano Maria, Peter Patel-Schneider, Irene Polikoff, Eric Prud'hommeaux, Arthur Ryman (who also served as a co-editor until Feb 2016), Andy Seaborne, Harold Solbrig, Simon Steyskal, Ted Thibodeau, Bart van Leeuwen, Nicky van Oorschot

G.Revision History

This section is non-normative.

The detailed list of changes and their diffs can be found in theGit repository.

Summary of changes to this document since theProposed Recommendation of 8 June 2017:

H.References

H.1Normative references

[BCP47]
Tags for Identifying Languages. A. Phillips; M. Davis. IETF. September 2009. IETF Best Current Practice. URL:https://tools.ietf.org/html/bcp47
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL:https://tools.ietf.org/html/rfc2119
[rdf11-concepts]
RDF 1.1 Concepts and Abstract Syntax. Richard Cyganiak; David Wood; Markus Lanthaler. W3C. 25 February 2014. W3C Recommendation. URL:https://www.w3.org/TR/rdf11-concepts/
[sparql11-entailment]
SPARQL 1.1 Entailment Regimes. Birte Glimm; Chimezie Ogbuji. W3C. 21 March 2013. W3C Recommendation. URL:https://www.w3.org/TR/sparql11-entailment/
[sparql11-query]
SPARQL 1.1 Query Language. Steven Harris; Andy Seaborne. W3C. 21 March 2013. W3C Recommendation. URL:https://www.w3.org/TR/sparql11-query/
[turtle]
RDF 1.1 Turtle. Eric Prud'hommeaux; Gavin Carothers. W3C. 25 February 2014. W3C Recommendation. URL:https://www.w3.org/TR/turtle/

H.2Informative references

[json-ld]
JSON-LD 1.0. Manu Sporny; Gregg Kellogg; Markus Lanthaler. W3C. 16 January 2014. W3C Recommendation. URL:https://www.w3.org/TR/json-ld/
[shacl-ucr]
SHACL Use Cases and Requirements. Simon Steyskal; Karen Coyle. W3C. 22 January 2016. W3C Working Draft. URL:https://www.w3.org/TR/shacl-ucr/


[8]ページ先頭

©2009-2025 Movatter.jp