rdflib 2.2.34 → 2.2.35-2bb9ed0b
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/dist/515.rdflib.min.js +3 -0
- package/dist/515.rdflib.min.js.map +1 -0
- package/dist/789.rdflib.min.js +1 -0
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -2
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +57 -85
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -106
- package/esm/default-graph.js +13 -33
- package/esm/empty.js +8 -26
- package/esm/factories/canonical-data-factory.js +33 -30
- package/esm/factories/extended-term-factory.js +18 -14
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1364 -1668
- package/esm/formula.js +631 -739
- package/esm/index.js +31 -51
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +41 -86
- package/esm/literal.js +120 -157
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1008 -1090
- package/esm/named-node.js +69 -99
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -97
- package/esm/node.js +1 -2
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -2
- package/esm/query.js +15 -30
- package/esm/rdfaparser.js +775 -846
- package/esm/rdfxmlparser.js +348 -365
- package/esm/serialize.js +2 -3
- package/esm/serializer.js +834 -889
- package/esm/sparql-to-query.js +0 -2
- package/esm/statement.js +52 -72
- package/esm/store.js +852 -963
- package/esm/types.js +26 -21
- package/esm/update-manager.js +963 -1104
- package/esm/updates-via.js +104 -134
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +4 -5
- package/esm/utils-js.js +5 -6
- package/esm/utils.js +7 -6
- package/esm/variable.js +32 -58
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +56 -83
- package/lib/class-order.js +2 -3
- package/lib/collection.js +69 -104
- package/lib/default-graph.js +13 -32
- package/lib/empty.js +8 -25
- package/lib/factories/canonical-data-factory.js +36 -34
- package/lib/factories/extended-term-factory.js +19 -16
- package/lib/factories/factory-types.js +2 -3
- package/lib/factories/rdflib-data-factory.js +10 -13
- package/lib/fetcher.js +1394 -1693
- package/lib/formula.js +631 -738
- package/lib/index.js +66 -89
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +3 -4
- package/lib/lists.js +47 -87
- package/lib/literal.js +120 -156
- package/lib/log.js +8 -9
- package/lib/n3parser.js +1011 -1096
- package/lib/named-node.js +69 -98
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +72 -95
- package/lib/node.js +2 -4
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -2
- package/lib/query.js +19 -32
- package/lib/rdfaparser.js +777 -849
- package/lib/rdfxmlparser.js +350 -366
- package/lib/serialize.js +2 -3
- package/lib/serializer.js +838 -892
- package/lib/sparql-to-query.js +0 -2
- package/lib/statement.js +54 -74
- package/lib/store.js +873 -978
- package/lib/types.js +22 -43
- package/lib/update-manager.js +972 -1111
- package/lib/updates-via.js +105 -134
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -4
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +11 -13
- package/lib/utils.js +6 -7
- package/lib/variable.js +34 -60
- package/lib/xsd-internal.js +2 -3
- package/lib/xsd.js +3 -4
- package/package.json +31 -31
- package/src/n3parser.js +1 -1
- package/src/rdfxmlparser.js +2 -1
- package/src/serializer.js +1 -1
- package/.babelrc +0 -20
- package/dist/670.rdflib.min.js +0 -1
- package/dist/730.rdflib.min.js +0 -3
- package/dist/730.rdflib.min.js.map +0 -1
- /package/dist/{730.rdflib.min.js.LICENSE.txt → 515.rdflib.min.js.LICENSE.txt} +0 -0
package/lib/query.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.Query = void 0;
|
|
8
8
|
exports.indexedFormulaQuery = indexedFormulaQuery;
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
9
|
var _store = _interopRequireDefault(require("./store"));
|
|
12
10
|
var _defaultGraphUri = require("./utils/default-graph-uri");
|
|
13
11
|
var _log = _interopRequireDefault(require("./log"));
|
|
@@ -23,24 +21,27 @@ var _uri = require("./uri");
|
|
|
23
21
|
// Here we introduce for the first time a subclass of term: variable.
|
|
24
22
|
//
|
|
25
23
|
// SVN ID: $Id: query.js 25116 2008-11-15 16:13:48Z timbl $
|
|
24
|
+
|
|
26
25
|
// Variable
|
|
27
26
|
//
|
|
28
27
|
// Compare with BlankNode. They are similar, but a variable
|
|
29
28
|
// stands for something whose value is to be returned.
|
|
30
29
|
// Also, users name variables and want the same name back when stuff is printed
|
|
31
|
-
/* jsl:option explicit */
|
|
32
|
-
|
|
30
|
+
/* jsl:option explicit */ // Turn on JavaScriptLint variable declaration checking
|
|
31
|
+
|
|
33
32
|
/**
|
|
34
33
|
* Query class, for tracking queries the user has in the UI.
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
35
|
+
class Query {
|
|
36
|
+
constructor(name, id) {
|
|
37
|
+
this.pat = new _store.default(); // The pattern to search for
|
|
38
|
+
this.vars = []; // Used by UI code but not in query.js
|
|
39
|
+
// this.orderBy = [] // Not used yet
|
|
40
|
+
this.name = name;
|
|
41
|
+
this.id = id;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
44
45
|
/**
|
|
45
46
|
* This function will match a pattern to the current Store
|
|
46
47
|
*
|
|
@@ -96,7 +97,6 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
96
97
|
b[self] = other;
|
|
97
98
|
return [[b, null]]; // Match
|
|
98
99
|
}
|
|
99
|
-
|
|
100
100
|
actual = self;
|
|
101
101
|
}
|
|
102
102
|
if (!actual.complexType) {
|
|
@@ -128,11 +128,9 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
128
128
|
if (self.length !== other.length) {
|
|
129
129
|
return []; // no way
|
|
130
130
|
}
|
|
131
|
-
|
|
132
131
|
if (!self.length) {
|
|
133
132
|
return [[[], null]]; // Success
|
|
134
133
|
}
|
|
135
|
-
|
|
136
134
|
var nbs = unifyTerm(self[0], other[0], bindings, formula);
|
|
137
135
|
if (nbs.length === 0) {
|
|
138
136
|
return nbs;
|
|
@@ -155,13 +153,11 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
155
153
|
bindings2[v] = nb[v]; // copy
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
|
-
|
|
159
156
|
for (v in bindings) {
|
|
160
157
|
if (bindings.hasOwnProperty(v)) {
|
|
161
158
|
bindings2[v] = bindings[v]; // copy
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
|
|
165
161
|
nbs2 = unifyContents(self.slice(1), other.slice(1), bindings2, formula);
|
|
166
162
|
m = nbs2.length;
|
|
167
163
|
for (j = 0; j < m; j++) {
|
|
@@ -269,7 +265,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
269
265
|
};
|
|
270
266
|
|
|
271
267
|
// An optional branch hoards its results.
|
|
272
|
-
var OptionalBranch = function
|
|
268
|
+
var OptionalBranch = function (junction) {
|
|
273
269
|
this.count = 0;
|
|
274
270
|
this.done = false;
|
|
275
271
|
this.results = [];
|
|
@@ -308,7 +304,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
308
304
|
terms = [item.subject, item.predicate, item.object, item.why];
|
|
309
305
|
ind = [f.subjectIndex, f.predicateIndex, f.objectIndex, f.whyIndex];
|
|
310
306
|
for (i = 0; i < 4; i++) {
|
|
311
|
-
|
|
307
|
+
let t = terms[i];
|
|
312
308
|
// console.log(" Prepare (" + t + ") "+(t in bindings))
|
|
313
309
|
if (t.uri && t.uri === _defaultGraphUri.defaultGraphURI) {// chrome:session
|
|
314
310
|
// console.log(' query: Ignoring slot ' + i)
|
|
@@ -320,13 +316,11 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
320
316
|
if (f.redirections[f.id(t)]) {
|
|
321
317
|
t = f.redirections[f.id(t)]; // redirect
|
|
322
318
|
}
|
|
323
|
-
|
|
324
319
|
termIndex = ind[i][f.id(t)];
|
|
325
320
|
if (!termIndex) {
|
|
326
321
|
item.index = [];
|
|
327
322
|
return false; // Query line cannot match
|
|
328
323
|
}
|
|
329
|
-
|
|
330
324
|
if (item.index === null || item.index.length > termIndex.length) {
|
|
331
325
|
// Find smallest index
|
|
332
326
|
item.index = termIndex;
|
|
@@ -362,7 +356,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
362
356
|
*
|
|
363
357
|
* Will fetch linked data from the web iff the knowledge base an associated source fetcher (f.fetcher)
|
|
364
358
|
***/
|
|
365
|
-
var match = function
|
|
359
|
+
var match = function (f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
366
360
|
_log.default.debug('Match begins, Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
367
361
|
|
|
368
362
|
// log.debug("match: f has "+f.statements.length+", g has "+g.statements.length)
|
|
@@ -381,7 +375,6 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
381
375
|
br[b] = new OptionalBranch(junction); // Allocate branches to prevent premature ending
|
|
382
376
|
br[b].pattern_debug = g.optional[b]; // for diagnotics only
|
|
383
377
|
}
|
|
384
|
-
|
|
385
378
|
for (b = 0; b < g.optional.length; b++) {
|
|
386
379
|
br[b].count = br[b].count + 1; // Count how many matches we have yet to complete
|
|
387
380
|
match(f, g.optional[b], bindingsSoFar, '', fetcher, callback, br[b]);
|
|
@@ -391,7 +384,6 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
391
384
|
_log.default.debug('Match ends -- success , Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
392
385
|
return; // Success
|
|
393
386
|
}
|
|
394
|
-
|
|
395
387
|
var item;
|
|
396
388
|
var i;
|
|
397
389
|
var n = pattern.length;
|
|
@@ -401,7 +393,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
401
393
|
if (fetcher) {
|
|
402
394
|
// Fetcher is used to fetch URIs, function first term is a URI term, second is the requester
|
|
403
395
|
var id = 'match' + matchIndex++;
|
|
404
|
-
var fetchResource = function
|
|
396
|
+
var fetchResource = function (requestedTerm, id) {
|
|
405
397
|
var docuri = requestedTerm.uri.split('#')[0];
|
|
406
398
|
fetcher.nowOrWhenFetched(docuri, undefined, function (ok, body, xhr) {
|
|
407
399
|
if (!ok) {
|
|
@@ -419,7 +411,6 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
419
411
|
fetchResource(bindingsSoFar[item.subject], id);
|
|
420
412
|
return; // only look up one per line this time, but we will come back again though match
|
|
421
413
|
}
|
|
422
|
-
|
|
423
414
|
if (bindingsSoFar[item.object] !== undefined && bindingsSoFar[item.object].uri && fetcher && fetcher.getState((0, _uri.docpart)(bindingsSoFar[item.object].uri)) === 'unrequested') {
|
|
424
415
|
fetchResource(bindingsSoFar[item.object], id);
|
|
425
416
|
return;
|
|
@@ -429,7 +420,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
429
420
|
match2(f, g, bindingsSoFar, level, fetcher, localCallback, branch);
|
|
430
421
|
}; // match
|
|
431
422
|
|
|
432
|
-
var constraintsSatisfied = function
|
|
423
|
+
var constraintsSatisfied = function (bindings, constraints) {
|
|
433
424
|
var res = true;
|
|
434
425
|
var x;
|
|
435
426
|
var test;
|
|
@@ -447,7 +438,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
447
438
|
};
|
|
448
439
|
|
|
449
440
|
/** match2 -- stuff after the fetch **/
|
|
450
|
-
var match2 = function
|
|
441
|
+
var match2 = function (f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
451
442
|
// post fetch
|
|
452
443
|
var pattern = g.statements;
|
|
453
444
|
var n = pattern.length;
|
|
@@ -465,7 +456,6 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
465
456
|
prepare(f, item, bindingsSoFar);
|
|
466
457
|
// if (item.index) console.log(' item.index.length ' + item.index.length)
|
|
467
458
|
}
|
|
468
|
-
|
|
469
459
|
pattern.sort(easiestQuery);
|
|
470
460
|
item = pattern[0];
|
|
471
461
|
// log.debug("Sorted pattern:\n"+pattern)
|
|
@@ -502,20 +492,17 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
502
492
|
bindings2[v] = newBindings1[v]; // copy
|
|
503
493
|
}
|
|
504
494
|
}
|
|
505
|
-
|
|
506
495
|
for (v in bindingsSoFar) {
|
|
507
496
|
if (bindingsSoFar.hasOwnProperty(v)) {
|
|
508
497
|
bindings2[v] = bindingsSoFar[v]; // copy
|
|
509
498
|
}
|
|
510
499
|
}
|
|
511
|
-
|
|
512
500
|
branch.count++; // Count how many matches we have yet to complete
|
|
513
501
|
onward++;
|
|
514
502
|
match(f, rest, bindings2, level + ' ', fetcher, callback, branch); // call match
|
|
515
503
|
}
|
|
516
504
|
}
|
|
517
505
|
}
|
|
518
|
-
|
|
519
506
|
branch.count--;
|
|
520
507
|
if (onward === 0) {
|
|
521
508
|
_log.default.debug('Match2 fails completely on ' + item);
|