ULB-Darmstadt / shacl-form

HTML5 web component for editing/viewing RDF data that conform to SHACL shapes
https://ulb-darmstadt.github.io/shacl-form/
MIT License
24 stars 4 forks source link

Generate named nodes #9

Closed angelo-v closed 5 months ago

angelo-v commented 5 months ago

When I set sh:nodeKind sh:IRI to a property the form generates a blank node for the linked resource and the form does not validate. I would like to have a new URI minted in that case, e.g with a UUID used as a fragment identifier

Example

Given the following shapes:

@prefix sh:   <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex:   <http://example.org#> .

ex:ExampleShape
    a           sh:NodeShape, rdfs:Class ;
    sh:property [ sh:name     "nested" ;
                  sh:path     ex:nested ;
                  sh:node     ex:NestedShape ;
                  sh:nodeKind sh:IRI ; ] .

ex:NestedShape
    a           sh:nodeShape ;
    sh:property [ sh:name "my value" ;
                  sh:path ex:exampleValue ; ] .

When filling the generated form currently the following data is generated:

@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org#>.

_:762be0f9-277a-4b70-91be-de55991eb5d0 ex:exampleValue "example".
_:d5a3e50e-e914-447f-a62e-69df2fd9d446 ex:nested _:762be0f9-277a-4b70-91be-de55991eb5d0;
    a ex:ExampleShape.

Resulting in the following error when validating against the same shape:

[
    a sh:ValidationResult ;
    sh:resultSeverity sh:Violation ;
    sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
    sh:sourceShape _:n247 ;
    sh:focusNode _:n246 ;
    sh:value _:n245 ;
    sh:resultPath ex:nested ;
    sh:resultMessage "Value does not have node kind sh:IRI" ;
] .

Expected result

The form should generate a named node e.g. by minting a fragment identifier using a UUID:

@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org#>.

<#762be0f9-277a-4b70-91be-de55991eb5d0> ex:exampleValue "example".
_:d5a3e50e-e914-447f-a62e-69df2fd9d446 ex:nested <#762be0f9-277a-4b70-91be-de55991eb5d0>;
    a ex:ExampleShape.
s-tittel commented 5 months ago

Could you provide a minimal example shapes graph that produces the error?

angelo-v commented 5 months ago

Sure, I updated the issue with a concrete example and detailed expectations, hope this helps

s-tittel commented 5 months ago

Thanks for reporting. It should work now as expected, please check version 1.4.2. Also there is a new data attribute data-values-namespace for the form that is used when creating new subject named nodes.

angelo-v commented 5 months ago

Awesome, thanks for the quick adjustment!