N3.js
N3.js copied to clipboard
Add support for empty graphs in the subject and object positions
This PR contains a fix for parsing empty graphs in subject and object positions when parsing empty graphs.
I added some test cases that check for empty graphs in the subject and object position, both in the default graph, and contained in a subgraph.
Note that this does NOT work for empty graphs in the predicate position. I have added tests for these as well, but they are commented out at the moment.
@Dexagod Are empty graphs supported by both N3 (seems yes) and RDF-star (citation needed)? If not, we will need a check on content type.
(I might be overcautious here, and maybe this code doesn't hit with RDF-star; just want to be sure.)
@Dexagod indeed we will only want to do this in N3 mode and error otherwise.
@RubenVerborgh this PR is not about RDF-Star; it is specifically for N3 content types in order to align with the decisions made in https://github.com/w3c/N3/issues/185 & https://github.com/rdfjs/types/issues/37 in the next major release.
In particular note that there are now N3 spec tests for what has been implemented here https://github.com/w3c/N3/pull/202.
Ack about it being for N3; just want to make sure it doesn't fire at the wrong time. But perhaps _readFormulaTail
is only accessed in N3 mode in any case.
Yep, synced on it with Jos and I indeed was mistaken. I'm setting it straight atm in terms of the true needing to be injected directly instead of with rdf:value. I'll double check to make sure the routine only fires in N3 mode.
Empty graphs are now correctly represented as "true"^^xsd:boolean.
I checked and the _readFormulaTail
function is only called in N3 mode.
Should I check if RDF-star is enabled and throw an error in case it is?
Should I check if RDF-star is enabled and throw an error in case it is?
No, I do not think we should error when N3 and star are both enabled. There is just no particular behavior we have to comply with as there is no N3-star spec.