Skip to content

Conversation

@HolgerKnublauch
Copy link
Contributor

@HolgerKnublauch HolgerKnublauch requested a review from afs November 17, 2025 10:34
@HolgerKnublauch HolgerKnublauch added the Node Expressions For SHACL 1.2 Node Expressions label Nov 17, 2025
<p><em>The remainder of this section is informative.</em></p>
<p>
Note that the scope in the evaluation of expression constraints contains the variable <code>value</code>
Note that the scope in the evaluation of expression constraints contains the <a href="#VarExpression">variable</a> <code>value</code>
Copy link
Contributor

@afs afs Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least:

Suggested change
Note that the scope in the evaluation of expression constraints contains the <a href="#VarExpression">variable</a> <code>value</code>
Note that the scope in the evaluation of expression constraints contains the <a href="#dfn-var-expression">variable</a> <code>value</code>

although this called a "var expression" not "a variable" so that seems to make it:

Suggested change
Note that the scope in the evaluation of expression constraints contains the <a href="#VarExpression">variable</a> <code>value</code>
Note that the scope in the evaluation of expression constraints contains the <a href="#VarExpression">var expression</a> <code>value</code>

The definition:

A blank node that is the subject of the following properties is called a var expression with the function name shnex:VarExpression:

says the blank node is the var expression and is an RDF term.

If you want to keep it as the current design, please keep using "var expression" and then shacl12-rules can define variable. (There are only two other uses of "variable" in the node expressions doc at the moment.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't even need to talk VarExpressions at all here. The key is the term "scope". And scope is defined in SHACL 1.2 core as

				<li><code>scope</code> is a map from (key) <a>nodes</a> to individual (value) <a>nodes</a>.
				The empty map is written as <code>{}</code>.

So I think we can avoid the term variable in that definition and just refer to mappings in the scope, where the key in the map is the value of shnex:var of the var expression.

I guess the proper fix is then to create a deep link to the scope definition and reference that from node expressions.

Copy link
Contributor

@afs afs Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map is from a string (taken from shnex:var) to RDF term.

If it is a node (RDF Term), then

[ shnex:var "foo" ] .
[ shnex:var "foo" ] .

is two different scope entries.

If there is no varExpression, how does a node expression work

  [ sparql:plus ( [ shnex:var foo" ] 1 ) ]

Something has to define

   exprEval([ shnex:var "foo" ])

and that to be an error if "foo" is not in the scope, which is returning an empty list from scope lookup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle to parse your response.

[ shnex:var "foo" ] .
[ shnex:var "foo" ] .

are two times the same expression. Why should those be "different scope entries"?

The sentence above the sparql:plus example seems unfinished. What do you mean?

We could change the handling of undefined variables but then how could we distinguish unbound (optional) parameters from those called by accident in a node expression? There is no "null" value here like in JavaScript.

Anyway, I made further adjustments to the PR and believe external documents can refer to the variable scope by name when they refer to evalExpr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle to parse your response.

[ shnex:var "foo" ] .
[ shnex:var "foo" ] .

are two times the same expression.

And what RDF term do they evaluate to? That's necessary because:

scope is a map from (key) nodes to individual (value) nodes.

(PS better to say "RDF term", not "nodes" which are the existing subject/objects of a graph)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably me still shaking cobwebs off from being AFK a while, but I need a reminder on one of the less intuitive ideas from RDF:

Is a literal a node?
Is a literal a term?

Update for RDF 1.2:

Is a triple term a node?
Is a triple term a term? (...If it isn't, why?)

Copy link
Contributor

@afs afs Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDF Terms : https://www.w3.org/TR/rdf12-concepts/#section-terms
IRIs, Blank nodes, literals, triple terms.

Nodes: https://www.w3.org/TR/rdf12-concepts/#dfn-node

"Nodes of a graph" -- the set of Subjects and Objects in use in a graph (not if only in the predicate position, of if only inside triple terms). As in "nodes and arcs" for graphs.

Triple terms: https://www.w3.org/TR/rdf12-concepts/#section-triple-terms
It is a triple in the role of an RDF term.

Is a literal a term?

Yes

Is a literal a node?

If it is in the graph

Is a triple term a node?

If it is in the graph as a <<( )>> thingy.

Is a triple term a term? (...If it isn't, why?)

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "foo" is not in the scope, then this rule applies

So scope is mapping a string, not a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it maps term to term, and I have taken the word "variable" out of the paragraph that started this thread.

Are you suggesting to rename shnex:var to something else?

Copy link
Contributor

@afs afs Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you say that the subject of [ shnex:var "foo" ] is (as in "describes", "represents" or "denotes", not in the RDF syntax where is a blank node) a variable with name "foo"?

After all:

shnex:var	sh:datatype xsd:string       The variable name, e.g. "focusNode".
            sh:minLength 1	        

Var expressions are expressions. They yield an RDF term when evaluated.
Here, they are the use of a variable in a role.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Node Expressions For SHACL 1.2 Node Expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No definition of "variable"

4 participants