The ShEx Test
extension is a very simple extension intended for testing ShEx extension frameworks.
Test
participates in validate and has side-effects.
The Test
extension has two functions:
print(msg)
- emit some mesagefail(msg)
- fail validationExample input schema with ShEx Test directives and input data:
PREFIX schema: <http://schema.org/> PREFIX eval: <http://shex.io/extensions/Eval/> BASE <http://schema.org/shex> <#Recipe> EXTRA a { a [schema:Recipe]; schema:datePublished . %eval:{ const val = ShEx.RdfTerm.getLiteralValue(ctx.object); isNaN(Date.parse(val)) ? [{type: "SemActViolation", message: `"${val} is not a date`}] : [] %} }
PREFIX schema: <http://schema.org/> <http://example.org/recipe> a schema:Recipe ; schema:datePublished "2020-01-01xx".
Eval
's semantics are entirely dependent on the host language and API.
Eval
is evaluated by the host lanugage's eval function or its equivalent.
langauge | platform/API | package | source |
---|---|---|---|
javascript | shexjs | packaged | src |