o-development / ldo-legacy

Linked Data Objects
Other
19 stars 2 forks source link

Result doesn't match type when one value is expected but multiple provided #23

Open mrkvon opened 10 months ago

mrkvon commented 10 months ago

In shex, if we define cardinality of a predicate to be 0-1, but in the RDF we have multiple predicates, we receive array of values instead of a single value.

Therefore, the type doesn't match the result.

Expected behavior

We expect LDO object to match type, even if RDF data are inconsistent. Not sure which of the multiple possible values should be chosen in this case.

Example

(omitting prefix definitions)

shape:

ex:FoafProfile EXTRA a {
  a [ foaf:Person ] ;
  foaf:name xsd:string ? ;
}

data:

:me
    a foaf:Person;
    foaf:name "Name", "OtherName".

result:

{ "name": ["Name", "OtherName"] }

Reproduce

You can see a minimal example on codesandbox or run it locally.

The code is here, shape is here and the output is

{"@id":"https://example.com/jane_doe/profile/card#me","type":{"@id":"Person"},"name":["Jane Doe","Jane"]}

Originally posted by @mrkvon in https://github.com/o-development/ldo/issues/22#issuecomment-1590228592