Resolve
RDF Terms

    Data based on @zazuko/vocabularies
    Click to Copy
    dash:ScriptSuggestionGenerator
    Click to Copy
    http://datashapes.org/dash#ScriptSuggestionGenerator

    Recommended prefix

    Copy 'PREFIX dash: <http://datashapes.org/dash#>'

    dash:

    lang:""
    Script suggestion generator
    lang:""
    A Suggestion Generator that is backed by an Active Data Shapes script. The script needs to return a JSON object or an array of JSON objects if it shall generate multiple suggestions. It may also return null to indicate that nothing was suggested. Note that the whole script is evaluated as a (JavaScript) expression, and those will use the last value as result. So simply putting an object at the end of your script should do. Alternatively, define the bulk of the operation as a function and simply call that function in the script. Each response object can have the following fields: { message: "The human readable message", // Defaults to the rdfs:label(s) of the suggestion generator add: [ // An array of triples to add, each triple as an array with three nodes [ subject, predicate, object ], [ ... ] ], delete: [ ... like add, for the triples to delete ] } Suggestions with neither added nor deleted triples will be discarded. At execution time, the script operates on the data graph as the active graph, with the following pre-bound variables: - focusNode: the NamedNode that is the sh:focusNode of the validation result - predicate: the NamedNode representing the predicate of the validation result, assuming sh:resultPath is a URI - value: the value node from the validation result's sh:value, cast into the most suitable JS object - the other pre-bound variables for the parameters of the constraint, e.g. in a sh:maxCount constraint it would be maxCount The script will be executed in read-only mode, i.e. it cannot modify the graph. Example with dash:js: ({ message: `Copy labels into ${graph.localName(predicate)}`, add: focusNode.values(rdfs.label).map(label => [ focusNode, predicate, label ] ) })