Skip to content

Commit 2e655fb

Browse files
committed
fix: make rdf-star work with n3 paths
1 parent 8e3b997 commit 2e655fb

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/N3Parser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,11 @@ export default class N3Parser {
886886
// If the triple was the subject, continue by reading the predicate.
887887
if (this._subject === null) {
888888
this._subject = quad;
889-
return this._readPredicate;
889+
// In N3 mode, the subject might be a path
890+
if (this._n3Mode)
891+
return this._getPathReader(this._readPredicateOrNamedGraph);
892+
else
893+
return this._readPredicate;
890894
}
891895
// If the triple was the object, read context end.
892896
else {

test/N3Parser-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,14 @@ describe('Parser', () => {
21052105
describe('A Parser instance for the N3 format testing rdfStar support', () => {
21062106
function parser() { return new Parser({ baseIRI: BASE_IRI, format: 'N3' }); }
21072107

2108+
describe('should parse RDF-star path',
2109+
shouldParse(parser, '<<<a> <b> <c>>>!<p1> <p2> <o> .',
2110+
[['a', 'b', 'c'], 'p1', '_:b0'], ['_:b0', 'p2', 'o']));
2111+
2112+
describe('should parse RDF-star path',
2113+
shouldParse(parser, '<<<a> <b> <c>>>!<p1>^<p2> <p3> <o> .',
2114+
[['a', 'b', 'c'], 'p1', '_:b0'], ['_:b1', 'p2', '_:b0'], ['_:b1', 'p3', 'o']));
2115+
21082116
describe('should parse RDF-star',
21092117
shouldParse(parser, '<<<a> <b> <c>>> <a> <b> .',
21102118
[['a', 'b', 'c'], 'a', 'b']));

0 commit comments

Comments
 (0)