rdflib.js
rdflib.js copied to clipboard
documentation: how to delete/replace nodes or literals?
I have some troubles understanding the documentation: how can I delete a literal or node? How can I replace a literal? Can I use sparql for this?
Can you provide some examples? Much thanks in advance.
UpdateManager
is what your looking for https://linkeddata.github.io/rdflib.js/Documentation/webapp-intro.html
I found a way: removeMany for removing nodes before adding the new ones. But is there a more elegant way?
I was seeking something to modify a document in the browser. But as I posted, I found the answer (except it is not very elegant).
I guess I don't so much think of adding Nodes to the store, as adding arcs, or triples, or Statements -- or facts in fact. So if you add a Node <#john>
or a Literal 30
it is always in the context of some fact like <#John> ex:age 30.
. You can change the triple <#John> ex:age 30. by replacing it with <#John> ex:age 31.
but you aren't really replacing the node 30
with the node 31
as any other triples in the graph keep 30 as 30. Does that make sense?
To add a triple like that you use
store.add(store.sym('https://.......#John') ns.ex('age'), 31)
Where the number 31 gets converted into the appropriate Literal