Skip to content

Documentation of SHACL functionality/interpretation as a form #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
josephguillaume opened this issue Mar 15, 2024 · 1 comment
Open

Comments

@josephguillaume
Copy link

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?

@smessie
Copy link
Member

smessie commented Mar 28, 2024

Thanks for your comment @josephguillaume.
This FormGenerator can generate form descriptions in multiple ontologies. One of those implemented ontologies is SHACL, which outputs a SHACL shape.
However, 2 additional ontologies are implemented: the UI ontology and RDF-Form.
And in fact, DASH could perfectly be another one, but at this time, it isn't though. (Which does not mean it wouldn't be a good idea.) I consider DASH to be a separate ontology as it extends SHACL, it should not replace SHACL, and I am convinced that being able to output a form description as a SHACL shape can still be beneficial, eg. when your renderer (or any other application) expects a SHACL shape.

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

When you select SHACL as output ontology, a SHACL shape will be outputted. However, this shape will also contain non-validating properties that, according to the SHACL spec, can be used for eg. form building.

It also means that any extensions to the form generator will be limited by SHACL's expressivity

Only if you select SHACL as output ontology. If you want to build a more expressive form, you should consider to choose for a different output ontology (at the top right), and that's exactly why I made the decision to support multiple ontologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants