n3 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/N3Parser.js CHANGED
@@ -36,6 +36,8 @@ class N3Parser {
36
36
  this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
37
37
  // Whether the log:isImpliedBy predicate is supported
38
38
  this._isImpliedBy = options.isImpliedBy;
39
+ // Whether an undeclared empty prefix resolves against the document IRI
40
+ this._implicitEmptyPrefix = !!options.implicitEmptyPrefix;
39
41
  // Whether an empty formula is read as the boolean literal true,
40
42
  // as in the N3 spec tests (opt-in until the next major version)
41
43
  this._emptyFormulaAsTrue = !!options.emptyFormulaAsTrue;
@@ -1406,6 +1408,8 @@ class N3Parser {
1406
1408
  this._sparqlStyle = false;
1407
1409
  this._prefixes = Object.create(null);
1408
1410
  this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2) : `b${blankNodePrefix++}_`;
1411
+ // Optionally bind the N3 empty prefix to the document's local namespace
1412
+ if (this._n3Mode && this._implicitEmptyPrefix && this._base) this._prefixes[''] = this._resolveIRI('#');
1409
1413
  this._prefixCallback = onPrefix || noop;
1410
1414
  this._versionCallback = onVersion || noop;
1411
1415
  this._inversePredicate = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/N3Parser.js CHANGED
@@ -29,6 +29,8 @@ export default class N3Parser {
29
29
  this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
30
30
  // Whether the log:isImpliedBy predicate is supported
31
31
  this._isImpliedBy = options.isImpliedBy;
32
+ // Whether an undeclared empty prefix resolves against the document IRI
33
+ this._implicitEmptyPrefix = !!options.implicitEmptyPrefix;
32
34
  // Whether an empty formula is read as the boolean literal true,
33
35
  // as in the N3 spec tests (opt-in until the next major version)
34
36
  this._emptyFormulaAsTrue = !!options.emptyFormulaAsTrue;
@@ -1522,6 +1524,9 @@ export default class N3Parser {
1522
1524
  this._prefixes = Object.create(null);
1523
1525
  this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2)
1524
1526
  : `b${blankNodePrefix++}_`;
1527
+ // Optionally bind the N3 empty prefix to the document's local namespace
1528
+ if (this._n3Mode && this._implicitEmptyPrefix && this._base)
1529
+ this._prefixes[''] = this._resolveIRI('#');
1525
1530
  this._prefixCallback = onPrefix || noop;
1526
1531
  this._versionCallback = onVersion || noop;
1527
1532
  this._inversePredicate = false;