Skip to content

Conversation

simonstey
Copy link
Contributor

@simonstey simonstey commented Aug 25, 2025

This pull request implements comprehensive changes to address Issue #484 regarding sequence processing naming inconsistencies in SHACL Node Expressions. The changes align the vocabulary and documentation with the sequence-based nature of node expression processing while maintaining backward compatibility through deprecation notices.

Problem Statement

SHACL Node Expressions are fundamentally sequence-based but were using set-style operation names, creating confusion:

  • Operations like union and minus suggested set semantics despite working on ordered sequences
  • The generic path property conflicted conceptually with constraint sh:path
  • Missing advanced sequence operations limited processing capabilities

Solution

1. Vocabulary Renaming for Sequence Semantics

Renamed Operations:

Deprecation Strategy:

  • Updated shacl.ttl with deprecation notices for sh:union and sh:minus
  • Maintained backward compatibility while guiding migration to new terms

2. Advanced Sequence Operations

New Operations Added:

  • shnex:flatMap - Applies expression to each input node and flattens results
  • shnex:findFirst - Returns first node conforming to a given shape
  • shnex:matchAll - Returns true if all nodes conform to a given shape

Files Modified

Vocabulary Files

  • shacl12-vocabularies/shnex.ttl

    • Added complete RDF definitions for FlatMap, FindFirst, and MatchAll expressions
    • Updated existing definitions with sequence-appropriate naming
    • Enhanced property comments for clarity
  • shacl12-vocabularies/shacl.ttl

    • Added deprecation notices for sh:union and sh:minus
    • Clear migration guidance to new sequence-based terms

Documentation

  • shacl12-node-expr/index.html
    • Renamed sections: UnionExpression → JoinExpression, MinusExpression → RemoveExpression

New Advanced Operations:

# Find first senior employee
sh:values [
    shnex:findFirst [
        shnex:nodes [ shnex:pathValues ex:employee ] ;
        shnex:findFirst ex:SeniorEmployeeShape ;
    ] ;
] .

# Check if all employees are active
sh:values [
    shnex:matchAll [
        shnex:nodes [ shnex:pathValues ex:employee ] ;
        shnex:matchAll ex:ActiveEmployeeShape ;
    ] ;
] .

Closes #484

@simonstey simonstey linked an issue Aug 25, 2025 that may be closed by this pull request
Copy link
Member

@TallTed TallTed left a comment

Choose a reason for hiding this comment

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

Small stuff

<div class="note">
<p><strong>Important:</strong> Note the distinction between <code>sh:path</code> and <code>shnex:pathValues</code>:</p>
<ul>
<li><code>sh:path</code> is used in <strong>property shapes</strong> to specify which property path should be constrained during validation. It defines what property or path the shape's constraints apply to.</li>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<li><code>sh:path</code> is used in <strong>property shapes</strong> to specify which property path should be constrained during validation. It defines what property or path the shape's constraints apply to.</li>
<li><code>sh:path</code> is used in <strong>property shapes</strong> to specify the property path that will be constrained during validation. It defines the property or path to which the shape's constraints apply.</li>

<p><strong>Important:</strong> Note the distinction between <code>sh:path</code> and <code>shnex:pathValues</code>:</p>
<ul>
<li><code>sh:path</code> is used in <strong>property shapes</strong> to specify which property path should be constrained during validation. It defines what property or path the shape's constraints apply to.</li>
<li><code>shnex:pathValues</code> is used in <strong>node expressions</strong> to specify which property path should be traversed to generate a sequence of values. It produces the actual values found by following the path.</li>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<li><code>shnex:pathValues</code> is used in <strong>node expressions</strong> to specify which property path should be traversed to generate a sequence of values. It produces the actual values found by following the path.</li>
<li><code>shnex:pathValues</code> is used in <strong>node expressions</strong> to specify the property path that will be traversed to generate a sequence of values. It produces the actual values found by following the path.</li>

The <a>output nodes</a> of the <a>minus expression</a> are the <a>nodes</a> in <code>N</code>
The <a>output nodes</a> of the <a>remove expression</a> are the <a>nodes</a> in <code>N</code>
except those that are also in <code>M</code>, preserving the order of <code>N</code>.
Nodes must be equal using <a>term equality</a>, i.e. <code>"01"^^xsd:integer</code> is distinct from <code>"1"^^xsd:integer</code>.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Nodes must be equal using <a>term equality</a>, i.e. <code>"01"^^xsd:integer</code> is distinct from <code>"1"^^xsd:integer</code>.
Nodes must be equal using <a>term equality</a>, i.e., <code>"01"^^xsd:integer</code> is distinct from <code>"1"^^xsd:integer</code>.

@HolgerKnublauch HolgerKnublauch added the Node Expressions For SHACL 1.2 Node Expressions label Oct 6, 2025
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.

Sequence processing
3 participants