@ulb-darmstadt/shacl-form 1.8.2 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -12
- package/dist/constants.d.ts +2 -0
- package/dist/form-bootstrap.js +69 -65
- package/dist/form-default.js +66 -62
- package/dist/form-material.js +99 -95
- package/dist/plugins/leaflet.js +7 -7
- package/dist/plugins/mapbox.js +19 -19
- package/package.json +2 -2
- package/src/constants.ts +2 -0
- package/src/property.ts +1 -0
- package/src/styles.css +2 -2
- package/src/util.ts +51 -26
package/README.md
CHANGED
|
@@ -128,28 +128,24 @@ In edit mode, `<shacl-form>` validates the constructed data graph using the libr
|
|
|
128
128
|
### Providing additional data to the shapes graph
|
|
129
129
|
|
|
130
130
|
Apart from setting the element attributes `data-shapes` or `data-shapes-url`, there are two ways of adding RDF data to the shapes graph:
|
|
131
|
-
1. While parsing the triples of the shapes graph, any encountered `owl:imports` predicate that has a valid HTTP URL
|
|
131
|
+
1. While parsing the triples of the shapes graph, any encountered `owl:imports` predicate that has a valid HTTP URL is fetched with the HTTP Accept header set to all of the [supported](#formats) MIME types. A successful response is parsed and added to a named graph. This graph is scoped (i.e. available) only to the node where the `owl:import` statement is defined on and all its sub nodes.
|
|
132
|
+
|
|
133
|
+
The [example shapes graph](https://ulb-darmstadt.github.io/shacl-form/#example) contains the following triples:
|
|
134
|
+
|
|
132
135
|
```
|
|
133
136
|
example:Attribution
|
|
134
|
-
owl:imports <https://w3id.org/nfdi4ing/metadata4ing/> ;
|
|
135
137
|
sh:property [
|
|
138
|
+
owl:imports <https://w3id.org/nfdi4ing/metadata4ing/> ;
|
|
136
139
|
sh:name "Role" ;
|
|
137
140
|
sh:path dcat:hadRole ;
|
|
138
141
|
sh:class prov:Role ;
|
|
139
142
|
] .
|
|
140
143
|
```
|
|
141
|
-
In this case, the URL references an ontology which among other things defines instances of class `prov:Role` that are then used to populate the "Role" dropdown in the form.
|
|
144
|
+
In this case, the URL references an ontology which among other things defines instances of class `prov:Role` that are then used to populate the "Role" dropdown in the form. The imported ontology is available only for rendering and validating this specific property.
|
|
142
145
|
|
|
143
146
|
2. <a id="classInstanceProvider"></a>The `<shacl-form>` element has a function `setClassInstanceProvider((className: string) => Promise<string>)` that registers a callback function which is invoked when a SHACL property has
|
|
144
147
|
an `sh:class` predicate. The expected return value is a (promise of a) string (e.g. in format `text/turtle`) that contains RDF class instance definitions of the given class.
|
|
145
148
|
|
|
146
|
-
Class hierarchies can be built using `rdfs:subClassOf`. Instance hierarchies can be modeled e.g. like:
|
|
147
|
-
```
|
|
148
|
-
ex:parent a ex:Class .
|
|
149
|
-
ex:child rdfs:subClassOf ex:parent; a ex:parent .
|
|
150
|
-
ex:grandchild rdfs:subClassOf ex:child; a ex:child .
|
|
151
|
-
```
|
|
152
|
-
|
|
153
149
|
In [this example](https://ulb-darmstadt.github.io/shacl-form/#example), the code:
|
|
154
150
|
|
|
155
151
|
```typescript
|
|
@@ -168,7 +164,13 @@ an `sh:class` predicate. The expected return value is a (promise of a) string (e
|
|
|
168
164
|
|
|
169
165
|
A more realistic use case of this feature is calling some API endpoint to fetch class instance definitions from existing ontologies.
|
|
170
166
|
|
|
171
|
-
###
|
|
167
|
+
### Use of SHACL sh:class
|
|
168
|
+
|
|
169
|
+
In case a property shape has a `sh:class`, all available graphs are scanned for instances of the given class to let the user choose from. `rdfs:subClassOf` is also considered when building the list of class instances.
|
|
170
|
+
|
|
171
|
+
`shacl-form` also supports class instance hierarchies modelled with `skos:broader` and/or `skos:narrower`. This is illustrated by the "Subject classification" property in the [example](https://ulb-darmstadt.github.io/shacl-form/#example).
|
|
172
|
+
|
|
173
|
+
### SHACL constraints sh:or and sh:xone
|
|
172
174
|
|
|
173
175
|
`<shacl-form>` supports using [sh:or](https://www.w3.org/TR/shacl/#OrConstraintComponent) and [sh:xone](https://www.w3.org/TR/shacl/#XoneConstraintComponent) to let users select between different options on nodes or properties.
|
|
174
176
|
The [example shapes graph](https://ulb-darmstadt.github.io/shacl-form/#example) has the following triples:
|
|
@@ -199,7 +201,7 @@ In case a node shape has a `sh:targetClass` and any graph, i.e.
|
|
|
199
201
|
- any graph loaded by `owl:imports`
|
|
200
202
|
- triples provided by [classInstanceProvider](#classInstanceProvider)
|
|
201
203
|
|
|
202
|
-
contains instances of that class, those can be linked in the respective SHACL property.
|
|
204
|
+
contains instances of that class, those can be linked in the respective SHACL property. The generated data graph will then just contain a reference to the instance, but not the triples that the instance consists of.
|
|
203
205
|
|
|
204
206
|
### SHACL shape inheritance
|
|
205
207
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare const RDF_PREDICATE_TYPE: import('n3').NamedNode<string>;
|
|
|
14
14
|
export declare const DCTERMS_PREDICATE_CONFORMS_TO: import('n3').NamedNode<string>;
|
|
15
15
|
export declare const RDFS_PREDICATE_SUBCLASS_OF: import('n3').NamedNode<string>;
|
|
16
16
|
export declare const OWL_PREDICATE_IMPORTS: import('n3').NamedNode<string>;
|
|
17
|
+
export declare const SKOS_PREDICATE_BROADER: import('n3').NamedNode<string>;
|
|
18
|
+
export declare const SKOS_PREDICATE_NARROWER: import('n3').NamedNode<string>;
|
|
17
19
|
export declare const SHACL_OBJECT_NODE_SHAPE: import('n3').NamedNode<string>;
|
|
18
20
|
export declare const SHACL_OBJECT_IRI: import('n3').NamedNode<string>;
|
|
19
21
|
export declare const SHACL_PREDICATE_PROPERTY: import('n3').NamedNode<string>;
|