[data-shapes] [Core & UI] Referencing external dynamic IRIs in sh:in for federated SHACL validation and UI option lists. (#846)

danielbeeke has just created a new issue for https://github.com/w3c/data-shapes:

== [Core & UI] Referencing external dynamic IRIs in sh:in for federated SHACL validation and UI option lists. ==

These two proposals combined allow someone to have federated references in their dataset, both on a validation level and in a rich user interface.

### Proposal: Allow `sh:in` to have a node expression.

__Given that:__
- UIs can have drop down lists with external data
- UIs can have autocomplete widgets with external data
- It's best if UI re-uses definitions from the core validation spec
- The SERVICE clause limitation has been made less strict
- Node expressions is something the UI also will support
```turtle
ex:propertyCity
  sh:path ex:city ;
  sh:in [
   sh:select """
  select ?city where {
   SERVICE <http://example.org/sparql> {
    ?city a ex:City .
   }
  }
  """ ;
  ] .  
```

__Notice:__
- It allows node expressions on `sh:in`, which is not a SHACL list.
- This query does not do filtering on the search term
 - My proposal is to use the given query results as pre bound bindings of $value for a new concept called a sh:LabelResolution.

I propose to leave it is up to the SHACL validation engine to decide to either support or ignore this syntax. 

### Proposal :`sh:LabelResolution`

```turtle
ex:propertyCity
  sh:path ex:city ;
  sh:in ( ex:Amsterdam ex:Rotterdam ex:NewYork ) ;
  sh:labelResolution ex:myLabels ;
].

ex:myLabels
 a sh:LabelResolution ;
 sh:select """
  select $value ?label where {
   $value rdfs:label ?label .
   filter(contains(?label, $searchTerm))
  }
 """ .
```

- `$value` will be pre-bound with the value node of which the SHACL renderer needs to render a label
- `$searchTerm` will always be bound.  If there is no search term, it will be bound to an empty string.
- This concept can be used with the `shui:EnumSelectEditor` and the `shui:AutocompleteEditor` and other places where it might apply.
- If no `sh:labelResolution` is given the SHACL renderer may fall back to it's own label resolution.

## Example using both proposals together
```turtle
ex:propertyCity
  sh:path ex:city ;
  sh:labelResolution ex:myLabels ;
  sh:in [
   sh:select """
  select ?city where {
   SERVICE <http://example.org/sparql> {
    ?city a ex:City .
   }
  }
  """ ;
  ] .  

ex:myLabels
 a sh:LabelResolution ;
 sh:select """
  select $value ?label where {
   SERVICE <http://example.org/sparql> {
    $value rdfs:label ?label .
    filter(contains(?label, $searchTerm))
   }
  }
 """ .
```

Please view or discuss this issue at https://github.com/w3c/data-shapes/issues/846 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 1 April 2026 14:06:28 UTC