In-browser demos of the shex.js implementation of Shape Expressions: one validator page, and a set of plugins it loads by URL, each installing one or more semantic-action extensions for a schema to dispatch and some adding a screen of their own. Links are marked by where they lead: try opens the validator on something, spec is a specification, doc documentation, npm a package and src source on GitHub.
Validate RDF data against a ShEx schema (ShExC, ShExJ or ShExR). One page; the query string says how it runs and what it opens on.
Calling convention. Parameters combine, so a link can say all of it: where to validate, which documents to open, what to load.
| parameter | what it does | example |
|---|---|---|
| worker=1 | validate in a Web Worker instead of on the page's thread | ?worker=1 &manifestURL=… |
| editors=textarea | plain textareas in place of the language-aware editors (the default; editors=1 in an old link means the default) |
?editors=textarea |
docwebapp-parameters.md
— the rest: which documents or manifest to open on (schemaURL, dataURL, shape-map, manifestURL), what to load (plugin, screen), where the data comes from (neighborhood, endpoint), and how results are shown (interface, explain, success).
Older links keep working: shex-simple.html (the
page's name until 2026), shex-worker.html, shexmap-simple.html
and shexmap-worker.html redirect here with the parameters they stood for.
Each is a semantic-action handler a schema dispatches by IRI, written
%prefix:{ … %} on a triple constraint, a shape or the
schema's start, and delivered as a plugin the validator loads.
try opens the validator on the
extension's examples; every entry names the plugin, so picking it
installs the handler. Size is the plugin's bundle, minified, on top
of the validator's.
| extension | example | |
|---|---|---|
Test
minimal test suite coverage of side-effects (print(…)) and validation control (fail(…)) |
<S> {
:p1 . %Test:{ print(o) %} ;
:p2 . %Test:{ fail("unwelcome p2: ", o) %} ?
} |
|
Eval
runs the action's code as JavaScript where this is bound to the matched triples |
<S> {
:p . %Eval:{
extensionStorage.object = this.triples[0].object.value;
return true;
%}
} |
|
| WASI WebAssembly Text, compiled in the page and run as a WASI command per invocation | <S> {
:p . %Wasi:{
(func $main (call $put_o) (call $nl))
%}
} |
|
| Test in wasm the Test extension again, as hand-written WebAssembly: the same IRI and the same schemas, so register one or the other | <S> {
:p . %Test:{
print(o) # handled by wasm
%}
} |
|
| ShExMap binds values as it validates for later materialization conformant to another schema | <Patient> {
fhir:givenName xsd:string %Map:{ bp:given %} ;
fhir:familyName xsd:string %Map:{ bp:family %}
} |
|
ShExReduce
yacc-like conventions to validate data and construct ASTs. JavaScript evaluation by srcextension-reduce-js |
<#BinOp> {
a [:Add :Sub :Mul :Div] %Reduce:{ $$ = {op: local($1)} %} ;
:left @<#Expr> %Reduce:{ $$ = {left: $1} %} ;
:right @<#Expr> %Reduce:{ $$ = {right: $1} %}
} %Reduce:{ $$ = Object.assign($rdf:type, $:left, $:right) %} |
|
SHACL-SPARQL
sh:sparql queries as actions: a SELECT fails on each row, an ASK passes when true, $this and $value pre-bound; removed from the shex npm package due to size |
:Event {
:start xsd:date ;
:end xsd:date ;
:part @:Event *
} %shacl-sparql:{
SELECT $this ("the event ends before it starts" AS ?message)
WHERE { $this :start ?start ; :end ?end . FILTER (?end < ?start) }
%} |
|
PathAssert
XPath-style steps from the focus node, [filters], closures, SPARQL's functions, some/every, implies; read through whatever data source the validator has, and a failure says what each part evaluated to |
:Event {
:start xsd:date ;
:end xsd:date ;
:part @:Event *
} %assert:{
:end >= :start
%}
:Book {
:isbn xsd:string %assert:{
empty(^:isbn except $this)
%}
} |
|
A plugin is one URL: a module that registers what it adds. hello-plugin.js is a working one in about forty lines: an extension that records what it matched, a pane, and a button that writes one into the other.
The same validator, as a library and a command line.
--extension loads any of the extensions; --endpoint and --wikibase the other data sourcesLong-running strawmen, each on a branch of its own and published beside this site with its own copy of the validator. The table (and the publication itself) comes from a data block in this page's source.