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 @@

List Expressions

The following example declares a property for instances of 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.

- - +

Filter Shape Expressions

@@ -1877,7 +2019,369 @@

OrderBy Expressions

+
+

Advanced Sequence Operations

+ +
+

FlatMap Expressions

+

+ + A blank node that is the subject of the following properties + is called a flat map expression, + with the function name shnex:FlatMapExpression: + + + + + + + + + + + + + + + + + + + + +
PropertyConstraintsDescription
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. +
+
+

+
+
EVALUATION OF FLAT MAP EXPRESSIONS
+

+ 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. +

+ + + +
+ + +
+

FindFirst Expressions

+

+ + A blank node that is the subject of the following properties + is called a find first expression, + with the function name shnex:FindFirstExpression: + + + + + + + + + + + + + + + + + + +
PropertyConstraintsDescription
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. +
+
+

+
+
EVALUATION OF FIND FIRST EXPRESSIONS
+

+ 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. +

+

+

+

+
+ +
+

MatchAll Expressions

+

+ + A blank node that is the subject of the following properties + is called a match all expression, + with the function name shnex:MatchAllExpression: + + + + + + + + + + + + + + + + + + +
PropertyConstraintsDescription
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. +
+
+

+
+
EVALUATION OF MATCH ALL EXPRESSIONS
+

+ 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. +

+

+

+

+
+ +

Aggregation Expressions

@@ -2110,6 +2614,10 @@

Sum Expressions

+ + + +

Miscellaneous Node Expressions

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