Working with rdf-ext in the browser - N3Parser and prefixes


#1

I’m using the full rdf-ext in the browser as per http://rdf-ext.bergnet.org/

I’m using the N3Parser to read a Readable stream through parser.import() and then add quads to a datastore.

Is there any way to get the prefixes and the URIs as stated in the turtle file either from the parser of from the datastore?


#2

You can add a event listener for prefix to the quad stream with: stream.on('prefix', (prefix, namespace) => {})

In general, it’s recommended to use Webpack to bundle own applications using rdf-ext.


#3

I tried that listener approach and it isn’t being triggered. the ‘data’ and ‘end’ triggers are working just fine, but nothing for ‘prefix’

Like you, I thought that this would have been the way, but apparently not.


#4

Can you please flesh out this example, because if I do e.g. stream.on('prefix', (prefix, namespace) => {console.log(prefix}) nothing gets written even though my Readable has prefixes and namespaces


#5

The version at http://rdf-ext.bergnet.org/ is a little bit outdated and I noticed that the version of the N3 parser included in the bundle doesn’t contain the prefix handling.

I will check if I can update the packages, but I think last time I tried to bundle the jsonld.js library with browserify, it caused a lot of problems. In general, we recommend building your own apps with Webpack.


#6

I’ve checked, but I can’t get the full build system running with the latest packages. I guess it would work with webpack, but changing it would be quite some work which I think is not worth the time. The dist will always have the problem that packages not included can’t be added easily. That’s why we recommend using webpack on the application level. Maybe ES modules can help to simplify prototyping in the future, but at the moment webpack is the only reliable option.


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