Rdf-ext datastore - blank node counter - resetting to zero


#1

I am using the full http://rdf-ext.bergnet.org/ in the browser.

I create a datastore from a turtle file by creating a Readable() stream, importing it into an N3Parser() and then adding the quads to a datastore.

I can then select blank nodes, but each time I do the number increments. Although I can see the N3Parser._resetBlankNodeIds in the file it is a private method. Is there any way to access this function and reset the counter?


#2

Not sure, but maybe you can access the index using an existing instance of a blank node like this: blankNode.constructor.nextId = 0

Why do you want to reset the counter? It should not matter which blank node ID is used, as long as the mapping in the parser works.


#3

I need it because I’m making diagrams and so it helps to have a consistent numbering. Consequently, I would ideally like to reset the counter before creating another datastore, but at the moment creating another doesn’t reset the counter. I need to reload my web page in order to do that.

However, thanks for the suggestion. I can try it out


#4

Thanks… Worked. Perhaps needs making a little more efficient, so suggestions welcome
http://semantechs.co.uk/turtle-editor-viewer/


#5

If you go in the direction of using webpack, like recommended in the other thread, you could use @rdfjs/term-map with the blank node as the key and a counter value as the value.