diff --git a/shacl12-node-expr/index.html b/shacl12-node-expr/index.html index d7e72606..834f97f4 100644 --- a/shacl12-node-expr/index.html +++ b/shacl12-node-expr/index.html @@ -1106,10 +1106,10 @@
rdfs:Class
where the values are derived from the values of the path rdfs:subClassOf*
but with the constants from the list ( owl:Thing rdfs:Resource ) removed using
- shnex:minus.
+ shnex:remove.
-
-
-
-
- A blank node that is the subject of the following properties
- is called a union expression with the function name shnex:UnionExpression:
-
-
-
-
- Property
- Constraints
- Description
-
-
-
-
-
-
- shnex:union
- A well-formed SHACL list where each member is a well-formed node expression.
-
-
- The node expressions that shall be unioned.
-
-
- Let members be the members of the value of shnex:union in the union expression.
- The output nodes of the union expression are the concatenation of all output nodes
- for each node expression NE in members, using evalExpr(NE, focusGraph, focusNode, scope).
- The order is preserved, evaluating the members from left to right and keeping the order of each list of output nodes.
-
The remainder of this section is informative.
-- Note that a union expression may produce duplicate output nodes if the individual output nodes overlap. - Use shnex:distinct to eliminate duplicates. -
+
+
+ A blank node that is the subject of the following properties
+ is called a concat expression, with the function name shnex:ConcatExpression:
+
+
+
+
+ Property
+ Constraints
+ Description
+
+
+
+
+
+
+ shnex:concat
+ A well-formed SHACL list where each member is a well-formed node expression.
+
+
+ The node expressions that shall be concatenated.
+
+
- The Example for shnex:distinct uses shnex:union.
+ Let members be the members of the value of shnex:concat in the concat expression.
+ The output nodes of the concat expression are the concatenation of all output nodes
+ for each node expression NE in members, using evalExpr(NE, focusGraph, focusNode, scope).
+ The order is preserved, evaluating the members from left to right and keeping the order of each list of output nodes.
The remainder of this section is informative.
++ Note that a concat expression may produce duplicate output nodes if the individual output nodes overlap. + Use shnex:distinct to eliminate duplicates. +
+
+ The following example declares a derived property ex:allRelatives
+ that concatenates the values of ex:parent and ex:sibling.
+ The shnex:concat expression takes a list of node expressions and returns
+ all nodes from each expression in sequence from left to right.
+
+ Evaluation trace: +
++ The evaluation proceeds as follows: +
+shnex:pathValues ex:parent with focus node ex:Person1
+ produces: [ex:Parent1, ex:Parent2]
+ shnex:pathValues ex:sibling with focus node ex:Person1
+ produces: [ex:Sibling1, ex:Sibling2, ex:Sibling3]
+ [ex:Parent1, ex:Parent2, ex:Sibling1, ex:Sibling2, ex:Sibling3]
+
+ More abstractly, concatenating [1, 2] and [3, 4, 5] results in [1, 2, 3, 4, 5]
+ with all elements preserved in order from left to right.
+
-
+
A blank node that is the subject of the following properties
- is called a minus expression with the function name shnex:MinusExpression:
+ is called a remove expression, with the function name shnex:RemoveExpression:
Property
@@ -1581,7 +1673,7 @@ Minus Expressions
-
+ shnex:minusshnex:remove
A well-formed node expression.
@@ -1602,23 +1694,73 @@ Minus Expressions
- Let minus be the value of shnex:minus
- and nodes be the value of shnex:nodes in the minus expression.
- Let M be the output nodes of evalExpr(minus, focusGraph, focusNode, scope).
+ Let remove be the value of shnex:remove
+ and nodes be the value of shnex:nodes in the remove expression.
+ Let M be the output nodes of evalExpr(remove, focusGraph, focusNode, scope).
Let N be the output nodes of evalExpr(nodes, focusGraph, focusNode, scope).
- The output nodes of the minus expression are the nodes in N
+ The output nodes of the remove expression are the nodes in N
except those that are also in M, preserving the order of N.
- Nodes must be equal using term equality, i.e. "01"^^xsd:integer is distinct from "1"^^xsd:integer.
+ Nodes must be equal using term equality, i.e., "01"^^xsd:integer is distinct from "1"^^xsd:integer.
The remainder of this section is informative.
+
+ The following example declares a derived property, ex:availableAuthors,
+ that returns all persons who are authors, except those who are currently on leave.
+ The shnex:remove expression takes the nodes from shnex:nodes (all authors)
+ and removes the nodes returned by the shnex:remove expression (authors on leave).
+
- The List Expression example uses shnex:minus.
+ Evaluation trace:
+ The evaluation proceeds as follows: +
+shnex:nodes [shnex:pathValues ex:author] with focus node ex:PublisherA
+ produces: [ex:Author1, ex:Author1, ex:Author1, ex:Author2, ex:Author2]
+ shnex:remove [shnex:pathValues ex:authorOnLeave] with focus node ex:PublisherA
+ produces: [ex:Author1, ex:Author1]
+ ex:Author1 from the nodes list, preserving order:
+ [ex:Author2, ex:Author2]
+
+ More abstractly, removing [1, 1] from [1, 1, 1, 2, 2] results in [2, 2]
+ because all instances of 1 are removed (not just the first occurrence).
+
+
+ A blank node that is the subject of the following properties
+ is called a flat map expression,
+ with the function name shnex:FlatMapExpression:
+
+
+
+
+
+
+
+
+ Property
+ Constraints
+ Description
+
+
+
+ shnex:flatMap
+ A well-formed node expression.
+
+
+ The node expression that is applied to each input node.
+
+
+
+
+
+ shnex:nodes
+ A well-formed node expression.
+
+
+ The input nodes. If omitted, defaults to the focus node.
+
+
+ Let flatMap be the value of shnex:flatMap
+ and nodes be the value of shnex:nodes in a flat map expression.
+ If shnex:nodes is not specified, let nodes be the focus node.
+
+ Let N be the output nodes of
+ evalExpr(nodes, focusGraph, focusNode, scope).
+
+ For each node n in N, let Mn be the output nodes of
+ evalExpr(flatMap, focusGraph, n, scope).
+
+ The output nodes of the flat map expression are produced by concatenating all sequences
+ Mn in the order of the corresponding nodes n in N.
+
The remainder of this section is informative.
+
+ The shnex:flatMap operation applies an expression to each input node and flattens the results
+ into a single sequence. This is particularly useful when combining results from multiple path traversals
+ or when working with nested structures.
+
+ A key aspect of shnex:flatMap is that the focus node changes for each iteration.
+ For each node produced by the shnex:nodes expression, that node becomes the focus node
+ when evaluating the shnex:flatMap expression. This allows relative path expressions to work correctly
+ at each level of nesting. The output sequences are then concatenated in order, preserving both the order
+ of input nodes and the order of results within each output sequence.
+
+ Unlike operations that remove duplicates, shnex:flatMap preserves all results, including duplicates.
+ If duplicate elimination is desired, use shnex:distinct to post-process the results.
+
+ The following example illustrates the use of shnex:flatMap to derive a property
+ ex:allSkills that collects all skills from all employees of a company.
+ For each employee of the company, the flatMap operation applies a path expression to retrieve their skills,
+ and flattens the resulting skill sequences into a single comprehensive list.
+
+ Evaluation trace: +
+shnex:nodes [shnex:pathValues ex:employee] with focus node ex:CompanyA
+ produces: [ex:Employee1, ex:Employee2, ex:Employee3]
+ n, evaluate shnex:flatMap [shnex:pathValues ex:skill]
+ with focus node n:
+ ex:Employee1 → ["Java", "Python", "SQL"]ex:Employee2 → ["Python", "JavaScript"]ex:Employee3 → ["Java", "DevOps"]["Java", "Python", "SQL", "Python", "JavaScript", "Java", "DevOps"]
+ shnex:distinct to remove duplicates from the flattened result.
+ shnex:filterShape to apply an additional shape constraint to the
+ flattened nodes.
+ shnex:limit to restrict the flattened result to the first N nodes.
+
+
+ A blank node that is the subject of the following properties
+ is called a find first expression,
+ with the function name shnex:FindFirstExpression:
+
+
+
+
+ Property
+ Constraints
+ Description
+
+
+
+
+
+ shnex:findFirst
+ A well-formed shape.
+
+
+ The shape that the matching node must conform to.
+
+
+
+
+
+ shnex:nodes
+ A well-formed node expression.
+
+
+ The input nodes. If omitted, defaults to the focus node.
+
+
+ Let shape be the value of shnex:findFirst
+ and nodes be the value of shnex:nodes in a find first expression.
+ If shnex:nodes is not specified, let nodes be the focus node.
+ Let N be the output nodes of evalExpr(nodes, focusGraph, focusNode, scope).
+ The output nodes of the find first expression contain exactly the first node n
+ in N that conforms to the shape shape,
+ or an empty sequence if no such node exists.
+
The remainder of this section is informative.
+
+ The shnex:findFirst operation finds the first node in a sequence that conforms to a given shape.
+
+ The following example illustrates the use of shnex:findFirst to derive a property
+ ex:seniorEmployee that finds the first employee with more than five years of experience.
+ The shnex:findFirst operation tests each employee against a shape that validates their years of service.
+
+
+
+ A blank node that is the subject of the following properties
+ is called a match all expression,
+ with the function name shnex:MatchAllExpression:
+
+
+
+
+ Property
+ Constraints
+ Description
+
+
+
+
+
+ shnex:matchAll
+ A well-formed shape.
+
+
+ The shape that all input nodes must conform to.
+
+
+
+
+
+ shnex:nodes
+ A well-formed node expression.
+
+
+ The input nodes. If omitted, defaults to the focus node.
+
+
+ Let shape be the value of shnex:matchAll
+ and nodes be the value of shnex:nodes in the match all expression.
+ If shnex:nodes is not specified, let nodes be the focus node.
+ Let N be the output nodes of evalExpr(nodes, focusGraph, focusNode, scope).
+ The output nodes of the match all expression contain the boolean true if
+ every node n in N conforms to the shape shape;
+ otherwise the output contains the boolean false.
+
The remainder of this section is informative.
+
+ The shnex:matchAll operation returns true if all nodes in a sequence conform to a given shape,
+ false otherwise.
+
+ The following example illustrates the use of shnex:matchAll to derive a property
+ ex:allEmployeesActive that checks whether all employees of a company are currently active.
+ The match all operation tests each employee against a shape that validates their active status.
+
+
diff --git a/shacl12-vocabularies/shacl.ttl b/shacl12-vocabularies/shacl.ttl index b0c08331..bf3c7291 100644 --- a/shacl12-vocabularies/shacl.ttl +++ b/shacl12-vocabularies/shacl.ttl @@ -1848,7 +1848,10 @@ sh:intersection rdfs:comment "Deprecated with SHACL 1.2: replaced by shnex:intersection."@en . sh:union - rdfs:comment "Deprecated with SHACL 1.2: replaced by shnex:union."@en . + rdfs:comment "Deprecated with SHACL 1.2: replaced by shnex:concat."@en . + +sh:minus + rdfs:comment "Deprecated with SHACL 1.2: replaced by shnex:remove."@en . # Rules ----------------------------------------------------------------------- diff --git a/shacl12-vocabularies/shnex.ttl b/shacl12-vocabularies/shnex.ttl index e9dcc051..8637923f 100644 --- a/shacl12-vocabularies/shnex.ttl +++ b/shacl12-vocabularies/shnex.ttl @@ -367,35 +367,35 @@ shnex:min . -# Minus Expressions ----------------------------------------------------------- +# Remove Expressions ----------------------------------------------------------- -shnex:MinusExpression +shnex:RemoveExpression a sh:NamedParameterExpressionFunction ; - rdfs:label "Minus expression"@en ; - rdfs:comment "A SHACL node expression that returns the values of a given node expression (sh:nodes) except for those returned by another node expression (sh:minus)."@en ; + rdfs:label "Remove expression"@en ; + rdfs:comment "A SHACL node expression that returns the values of a given node expression (sh:nodes) except for those returned by another node expression (sh:remove)."@en ; rdfs:subClassOf sh:NamedParameterExpression ; - sh:parameter shnex:MinusExpression-minus ; - sh:parameter shnex:MinusExpression-nodes ; + sh:parameter shnex:RemoveExpression-remove ; + sh:parameter shnex:RemoveExpression-nodes ; rdfs:isDefinedBy shnex: ; . -shnex:MinusExpression-minus +shnex:RemoveExpression-remove a sh:Parameter ; - sh:path shnex:minus ; + sh:path shnex:remove ; sh:keyParameter true ; rdfs:isDefinedBy shnex: ; . -shnex:MinusExpression-nodes +shnex:RemoveExpression-nodes a sh:Parameter ; sh:path shnex:nodes ; sh:name "nodes"@en ; sh:description "A node expression that produces the input nodes."@en ; rdfs:isDefinedBy shnex: ; . -shnex:minus +shnex:remove a rdf:Property ; - rdfs:label "minus"@en ; - rdfs:comment "In Minus Expressions, this property specifies the node expression that produces the values that shall be removed from the input nodes (sh:nodes)."@en ; - rdfs:domain shnex:MinusExpression ; + rdfs:label "remove"@en ; + rdfs:comment "In Remove Expressions, this property specifies the node expression that produces the values that shall be removed from the input nodes (sh:nodes)."@en ; + rdfs:domain shnex:RemoveExpression ; rdfs:isDefinedBy shnex: ; . @@ -519,27 +519,27 @@ shnex:sum . -# Union Expressions ----------------------------------------------------------- +# Concat Expressions ---------------------------------------------------------- -shnex:UnionExpression +shnex:ConcatExpression a sh:NamedParameterExpressionFunction ; - rdfs:label "Union expression"@en ; + rdfs:label "Concat expression"@en ; rdfs:comment "A SHACL node expression that can be used to returns the nodes that are found in either of the results of the listed node expression."@en ; rdfs:subClassOf sh:NamedParameterExpression ; - sh:parameter shnex:UnionExpression-union ; + sh:parameter shnex:ConcatExpression-concat ; rdfs:isDefinedBy shnex: ; . -shnex:UnionExpression-union +shnex:ConcatExpression-concat a sh:Parameter ; - sh:path shnex:union ; + sh:path shnex:concat ; sh:keyParameter true ; rdfs:isDefinedBy shnex: ; . -shnex:union +shnex:concat a rdf:Property ; - rdfs:label "union"@en ; - rdfs:comment "In Union Expressions, this property specifies the list of node expressions that shall be unioned."@en ; - rdfs:domain shnex:UnionExpression ; + rdfs:label "concat"@en ; + rdfs:comment "In Concat Expressions, this property specifies the list of node expressions that shall be concatenated."@en ; + rdfs:domain shnex:ConcatExpression ; rdfs:range rdf:List ; rdfs:isDefinedBy shnex: ; . @@ -570,3 +570,107 @@ shnex:var rdfs:domain shnex:VarExpression ; rdfs:range xsd:string ; . + + +# FlatMap Expressions --------------------------------------------------------- + +shnex:FlatMapExpression + a sh:NamedParameterExpressionFunction ; + rdfs:label "FlatMap expression"@en ; + rdfs:comment "A SHACL node expression that applies an expression to each input node and flattens the results into a single sequence."@en ; + rdfs:subClassOf sh:NamedParameterExpression ; + sh:parameter shnex:FlatMapExpression-flatMap ; + sh:parameter shnex:FlatMapExpression-nodes ; + rdfs:isDefinedBy shnex: ; +. +shnex:FlatMapExpression-flatMap + a sh:Parameter ; + sh:path shnex:flatMap ; + sh:keyParameter true ; + rdfs:isDefinedBy shnex: ; +. +shnex:FlatMapExpression-nodes + a sh:Parameter ; + sh:path shnex:nodes ; + sh:name "nodes"@en ; + sh:description "A node expression that produces the input nodes."@en ; + sh:optional true ; + rdfs:isDefinedBy shnex: ; +. +shnex:flatMap + a rdf:Property ; + rdfs:label "flatMap"@en ; + rdfs:comment "In FlatMap Expressions, this property specifies the node expression that is applied to each input node."@en ; + rdfs:domain shnex:FlatMapExpression ; + rdfs:isDefinedBy shnex: ; +. + + +# FindFirst Expressions ------------------------------------------------------- + +shnex:FindFirstExpression + a sh:NamedParameterExpressionFunction ; + rdfs:label "FindFirst expression"@en ; + rdfs:comment "A SHACL node expression that returns the first node from a sequence that satisfies a given predicate."@en ; + rdfs:subClassOf sh:NamedParameterExpression ; + sh:parameter shnex:FindFirstExpression-findFirst ; + sh:parameter shnex:FindFirstExpression-nodes ; + rdfs:isDefinedBy shnex: ; +. +shnex:FindFirstExpression-findFirst + a sh:Parameter ; + sh:path shnex:findFirst ; + sh:keyParameter true ; + rdfs:isDefinedBy shnex: ; +. +shnex:FindFirstExpression-nodes + a sh:Parameter ; + sh:path shnex:nodes ; + sh:name "nodes"@en ; + sh:description "A node expression that produces the input nodes."@en ; + sh:optional true ; + rdfs:isDefinedBy shnex: ; +. +shnex:findFirst + a rdf:Property ; + rdfs:label "findFirst"@en ; + rdfs:comment "In FindFirst Expressions, this property specifies the shape that the matching node must conform to."@en ; + rdfs:domain shnex:FindFirstExpression ; + rdfs:range sh:Shape ; + rdfs:isDefinedBy shnex: ; +. + + +# MatchAll Expressions -------------------------------------------------------- + +shnex:MatchAllExpression + a sh:NamedParameterExpressionFunction ; + rdfs:label "MatchAll expression"@en ; + rdfs:comment "A SHACL node expression that returns true if all nodes in a sequence satisfy a given predicate, false otherwise."@en ; + rdfs:subClassOf sh:NamedParameterExpression ; + sh:parameter shnex:MatchAllExpression-matchAll ; + sh:parameter shnex:MatchAllExpression-nodes ; + rdfs:isDefinedBy shnex: ; +. +shnex:MatchAllExpression-matchAll + a sh:Parameter ; + sh:path shnex:matchAll ; + sh:keyParameter true ; + rdfs:isDefinedBy shnex: ; +. +shnex:MatchAllExpression-nodes + a sh:Parameter ; + sh:path shnex:nodes ; + sh:name "nodes"@en ; + sh:description "A node expression that produces the input nodes."@en ; + sh:optional true ; + rdfs:isDefinedBy shnex: ; +. +shnex:matchAll + a rdf:Property ; + rdfs:label "matchAll"@en ; + rdfs:comment "In MatchAll Expressions, this property specifies the shape that all input nodes must conform to."@en ; + rdfs:domain shnex:MatchAllExpression ; + rdfs:range sh:Shape ; + rdfs:isDefinedBy shnex: ; +. \ No newline at end of file