CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 159
Description
We have web application that needs to be able to modify RDF lists from a triple store and propagate the changes back. To do this, we are utilizing jsonld-java to serialize the RDF into JSON-LD, modifying it in the web app, and then sending it back to be deserialized and stored in the triple store. Originally, we were using blank nodes like the ones shown in Turtle below.
<https://example.com> <https://example.com/property> _:a .
_:a a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "a" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b .
_:b a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "b" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:c .
_:c a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "c" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <https://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
However, we discovered that blank node lists are collapsed during serialization thus losing all the blank node IDs.
[ {
"@id" : "https://example.com",
"https://example.com/property" : [ {
"@list" : [ {
"@value" : "a"
}, {
"@value" : "b"
}, {
"@value" : "c"
} ]
} ]
} ]
With blank node IDs removed, we are no longer able to reference the existing RDF in the triple store to perform updates when the lists are modified in the web-app without much more complex logic. To avoid this, we skolemized the blank node IDs into IRIs.
<https://example.com> <https://example.com/property> <urn:a> .
<urn:a> a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "a" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <urn:b> .
<urn:b> a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "b" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <urn:c> .
<urn:c> a <https://www.w3.org/1999/02/22-rdf-syntax-ns#List> ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#first> "c" ;
<https://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <https://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
However, when serializing the skolemized triples, the IRI for the last element in the RDF list is hidden, in this case urn:c
. This leads to the same problem we were having when using blank node IDs.
[ {
"@id" : "https://example.com",
"https://example.com/property" : [ {
"@id" : "urn:a"
} ]
}, {
"@id" : "urn:a",
"@type" : [ "https://www.w3.org/1999/02/22-rdf-syntax-ns#List" ],
"https://www.w3.org/1999/02/22-rdf-syntax-ns#first" : [ {
"@value" : "a"
} ],
"https://www.w3.org/1999/02/22-rdf-syntax-ns#rest" : [ {
"@id" : "urn:b"
} ]
}, {
"@id" : "urn:b",
"@type" : [ "https://www.w3.org/1999/02/22-rdf-syntax-ns#List" ],
"https://www.w3.org/1999/02/22-rdf-syntax-ns#first" : [ {
"@value" : "b"
} ],
"https://www.w3.org/1999/02/22-rdf-syntax-ns#rest" : [ {
"@list" : [ {
"@value" : "c"
} ]
} ]
} ]
Issue #277 seems to be the point where the implementation changed from serializing lists in the manner we expect to this new compact way. Is there any way we can get around this so that the last blank node of a list is not collapsed?