Add an element to the end of a list

Hi,

I need to create a property with an rdf:List value, if the property
doesn't exist, or append an item to the existing list.

That seemed to exactly match the case "Add an element to the end of a
list" in Andy's document "Updating RDF Lists with SPARQL":
https://afs.github.io/rdf-lists-sparql#a-nameadd-lastaadd-an-element-to-the-end-of-a-list

However, it didn't work in my case when the list length was equal to
1. Then I tried running the SPARQL update from the document on an
empty Fuseki dataset and sure enough, it works for all cases except
when the list length is 1. Here's the resulting dataset:

<http://example/x3>  <http://example/p>
                ( 1 2 3 98 ) .

<http://example/x2>  <http://example/p>
                ( 1 2 98 ) .

<http://example/x1>  <http://example/p>
                ( 1 ) .

<http://example/x0>  <http://example/p>
                ( 99 ) .

I think this is due to the property path pattern ?list rdf:rest+ ?elt
which does not match lists of length 1.

Can someone confirm this and provide a complete version with a fix?
The document should probably be updated, too.

Thanks.

Martynas
atomgraph.com

Received on Friday, 4 March 2022 18:56:37 UTC