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?
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:dataTypeandsh:nodeKind. This contrasts with e.g. https://datashapes.org/forms.html which annotates a SHACL shape with editors and viewers.FormGenerator/app/routes/index.js
Lines 338 to 356 in d83b7d1
FormGenerator/app/routes/index.js
Lines 539 to 548 in d83b7d1
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?