- From: Eric Prud'hommeaux <eric@w3.org>
- Date: Wed, 29 Jun 2016 11:30:11 -0400
- To: public-data-shapes-wg <public-data-shapes-wg@w3.org>
In order to tie the surface syntax of ShEx to SHACL, I wrote up an abstract syntax for SHACL. I tried to use the same types as described in the SHACL document but I'd like folks to check it for consistency. Notation TypeName := label1:Type1, label2:Set[Type2] means TypeName has two component addressed by label1 and label2. label1 is a Type1 (defined elsewhere in the abstract syntax or in RDF standards) and label2 is a set of things matching Type2. Schema := shapes:Set[Shape] A Schema is a set of Shapes. (Do we care about schema boundaries?) Shape := label:IRI|BNode, scopes:Set[Scope], filters:Set[Shape], constraints:Set[Constraint] A Shape has a label of some IRI or BNode, and sets of scopes, filter shapes and constraints. The "in-scope" nodes are the nodes in the data graph which 1 match any of the scopes. 2 pass all of the filter Shapes. (Scopes in filter Shapes have no effect.) Validation returns the set of errors returned from testing each constraint against each "focus node" in the in-scope node. # Scopes Scope := ScopeNode|ScopeClass|PropertyScope|InversePropertyScope A Scope is either a ScopeNode or a ScopeClass or a PropertyScope. ScopeNode := node:IRI|Bnode # later demands told bnodes. A ScopeNode matches node in the data graph. ScopeClass := type:IRI A ScopeClass matches any node in the data graph with the triple (node rdf:type type). PropertyScope := predicate:IRI A PropertyScope matches any node in the data graph with a triple (node predicate _) where "_" is any node. InversePropertyScope := predicate:IRI A PropertyScope matches any node in the data graph with a triple (_ predicate node) where "_" is any node. # Constraints Constraint := NodeConstraint|PropertyConstraint| InversePropertyConstraint|Constraint A Constraint is either PropertyConstraint or InversePropertyConstraint or a NodeConstraint. Each type of Constraint selects a value node and tests it against a set of Paramenters. Parameters take arguments, including "numeric" which is the set of SPARQL numeric types enumerated in SPARQL Operand Data Types <http://www.w3.org/TR/sparql11-query/#operandDataTypes>. Exception: three Parameters, MinCount, MaxCount and UniqueLang, are evaluated against the set of all value nodes matching a PropertyConstraint or InversePropertyConstraint. NodeConstraint := parms:Set[NCParameter] Testing a NodeConstraint against a focus node returns all of the errors from testing each NCParameter against the the value node where the value node is the focus node. PropertyConstraint := predicate:IRI, parms:Set[PCParameter] Testing a NodeConstraint against a focus node returns all of the errors from testing each NCParameter against each value node in the triple (focus node, predicate, value node). InversePropertyConstraint := predicate:IRI, parms:Set[IPCParameter] Testing a NodeConstraint against a focus node returns all of the errors from testing each NCParameter against each value node in the triple (value node, predicate, focus node). Constraint := @@still fuzzy on what's permitted in a general constraint. Extrapolate from Closed? NP, PC and IPC Parameters are listed in the first table in <http://w3c.github.io/data-shapes/shacl/#h-constraints>. # Nary Parameters - evaluate a set of value nodes. ## Cardinality: PC, ICP MinCount := ref:numeric Testing a MinCount parameter against a set of value nodes returns an error if the number of value nodes is less than ref. MaxCount := ref:numeric Testing a MaxCount parameter against a set of value nodes returns an error if the number of value nodes is greater than ref. UniqueLang := b:boolean Testing a UniqueLang parameter against a set of value nodes returns an error if two or more of the value nodes are RDFLiterals with the same language tag. # Unary Parameters - evaluate a single value node. ## Logical operators: NC, PC, IPC And := shapes:Set[Shape] Testing an And parameter against a value node returns the errors from testing each of shapes against the value node. Or := shapes:Set[Shape] Testing an Or parameter against a value node returns an unspecified error if testing each of shapes against the value node returned an error. Not := shape:Shape Testing an Or parameter against a value node returns an unspecified error if testing shape against the value node returned no error. ## RDF term type of value node: NC, PC, IPC NodeKind := kind:"IRI"|"blank node"|"literal" Testing a NodeKind parameter against a value node returns an error if • kind = "IRI" and value node is not an IRI • kind = "blank node" and value node is not an blank node • kind = "literal" and value node is not an RDFLiteral ## Datatype: NC, PC Datatype := dt:IRI Testing a Datatype parameter against dt returns an error if the value node is not an RDFLiteral or of the datatype of the value node is not the same RDF term as dt. DatatypeIn := dts:Set[IRI] Testing a Datatype parameter against dt returns an error if the value node is not an RDFLiteral or of the datatype of the value node is not the set dts. ## XML Schema facets: ### XML Schema string facets: NC, PC, ICP MinLength: := ref:numeric Testing a MinLength paramenter against ref returns an error if the lexical form of the value node is longer than ref. MaxLength := ref:numeric Testing a MinLength paramenter against ref returns an error if the lexical form of the value node is shorter than ref. Pattern := pat:RDFLiteral Testing a Pattern paramenter against pat returns an error if evaluating the SPARQL regex function with the lexical form of value node and pat is false or results in a type error. ### XML Schema numeric facets: NC, PC MaxExclusive := ref:RDFLiteral Testing a MaxExclusive parameter against ref returns an error if the evaluation of (value node > ref) in SPARQL1.1 Operator Mapping returns false or results in a type error. MaxInclusive := ref:RDFLiteral Testing a MaxExclusive parameter against ref returns an error if the evaluation of (value node >= ref) in SPARQL1.1 Operator Mapping returns false or results in a type error. MinExclusive := ref:RDFLiteral Testing a MaxExclusive parameter against ref returns an error if the evaluation of (value node > ref) in SPARQL1.1 Operator Mapping returns false or results in a type error. MinInclusive := ref:RDFLiteral Testing a MaxExclusive parameter against ref returns an error if the evaluation of (value node >= ref) in SPARQL1.1 Operator Mapping returns false or results in a type error. @@ more Parameters to go, but you get the idea. -- -ericP office: +1.617.599.3509 mobile: +33.6.80.80.35.59 (eric@w3.org) Feel free to forward this message to any list for any purpose other than email address distribution. There are subtle nuances encoded in font variation and clever layout which can only be seen by printing this message on high-clay paper.
Received on Wednesday, 29 June 2016 15:30:18 UTC