-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDFJS compliance: blank node values should not be prepended by _:
#244
Comments
_:
This contains fixes for the following open non-RDFJS-compliance issues in jsonld: * digitalbazaar/jsonld.js#243 * digitalbazaar/jsonld.js#244
Closing as not a bug. If there's an actual bug here, please re-open and provide a test case with expected output and actual output that does not match. |
I also care about this issue! Right now, anybody trying to integrate jsonld.js with any other popular RDF library like n3.js has to manually run some snippet like this on the output of const dataset = await jsonld.toRDF(doc, {})
for (const quad of dataset) {
if (quad.subject.value.startsWith("_:")) {
quad.subject.value = quad.subject.value.slice(2)
}
if (quad.object.value.startsWith("_:")) {
quad.object.value = quad.object.value.slice(2)
}
if (quad.graph.value.startsWith("_:")) {
quad.graph.value = quad.graph.value.slice(2)
}
}
// *now* we can import `dataset` into an n3.js store... ... which is really annoying! A concrete test case would be: jsonld.toRDF({ "http://schema.org/knows": { "@id": "_:b1" } }, {}) which produces [
{
subject: { termType: 'BlankNode', value: '_:b0' },
predicate: { termType: 'NamedNode', value: 'http://schema.org/knows' },
object: { termType: 'BlankNode', value: '_:b1' },
graph: { termType: 'DefaultGraph', value: '' }
}
] but should produce [
{
subject: { termType: 'BlankNode', value: 'b0' },
predicate: { termType: 'NamedNode', value: 'http://schema.org/knows' },
object: { termType: 'BlankNode', value: 'b1' },
graph: { termType: 'DefaultGraph', value: '' }
}
] The relevant portion of the RDFJS spec was quoted in the original comment - the jsonld.js documentation doesn't explicitly mention RDFJS anywhere as far as I can tell, but it's clearly the intended representation. Edit: I should add that I'd be happy to open a pull request fixing this in lib/toRdf.js if you're interested, although I don't understand the rest of the codebase well enough to know if anything else depends on the current behavior |
@pietercolpaert would you mind reopening this? This is in fact a problem which bit me more than once |
I cannot re-open this very issue - please check with @dlongley who indicated a couple of years ago a new issue with a proposal for a PR with a test case will do the trick. Today I just use https://github.com/rubensworks/jsonld-streaming-parser.js instead |
So do I, mostly. But for a quick hack, |
PR #548 might address this, I'm not sure. |
The Also I don't think |
RDFJS defines in its specification that:
However, jsonld.js does not remove
_:
when executing the toRDF code. This can be found in multiple places. One example:jsonld.js/lib/toRdf.js
Line 103 in c6501fb
The text was updated successfully, but these errors were encountered: