Skip to content

Documentation of SHACL functionality/interpretation as a form #9

Description

@josephguillaume

Hi,

I'm commenting to help document the SHACL format used (as I understand it). I hope that's ok and apologies if it is already somewhere.

SHACL is used by hard coding fields used for different sh:dataType and sh:nodeKind. This contrasts with e.g. https://datashapes.org/forms.html which annotates a SHACL shape with editors and viewers.

async loadShaclForm(uri) {
const query = `
PREFIX sh: <http://www.w3.org/ns/shacl#>
SELECT ?targetClass ?type ?field ?nodeKind ?property ?label ?order ?minCount ?maxCount ?in
WHERE {
<${uri}> a sh:NodeShape;
sh:targetClass ?targetClass ;
sh:property ?field .
?field a sh:PropertyShape .
OPTIONAL { ?field sh:datatype ?type . }
OPTIONAL { ?field sh:nodeKind ?nodeKind . }
OPTIONAL { ?field sh:path ?property . }
OPTIONAL { ?field sh:name ?label . }
OPTIONAL { ?field sh:order ?order . }
OPTIONAL { ?field sh:minCount ?minCount . }
OPTIONAL { ?field sh:maxCount ?maxCount . }
OPTIONAL { ?field sh:in ?in . }
}`;

shaclTypeToWidget(type) {
switch (type) {
case 'http://www.w3.org/2001/XMLSchema#string':
return 'string';
case 'http://www.w3.org/ns/shacl#IRI':
return 'dropdown';
case 'http://www.w3.org/2001/XMLSchema#boolean':
return 'checkbox';
case 'http://www.w3.org/2001/XMLSchema#date':
return 'date';

This approach means that what is generated is a SHACL shape, not just a form.

It also means that any extensions to the form generator will be limited by SHACL's expressivity - I think SHACL would need to be used in non-standard ways to allow for e.g. how RDF-form handles image selection, file upload or even differentiating plain text vs rich text editing?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions