rdflib 2.2.21 → 2.2.22-b51259b5
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/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +9 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +61 -114
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -128
- package/esm/convert.js +1 -2
- package/esm/default-graph.js +14 -48
- package/esm/empty.js +8 -39
- package/esm/factories/canonical-data-factory.js +33 -65
- package/esm/factories/extended-term-factory.js +18 -25
- package/esm/factories/factory-types.js +3 -2
- package/esm/factories/rdflib-data-factory.js +9 -19
- package/esm/fetcher.js +1341 -1854
- package/esm/formula.js +639 -846
- package/esm/index.js +40 -76
- package/esm/jsonldparser.js +24 -49
- package/esm/jsonparser.js +1 -8
- package/esm/lists.js +47 -110
- package/esm/literal.js +120 -189
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1015 -1412
- package/esm/named-node.js +70 -119
- package/esm/namespace.js +2 -5
- package/esm/node-internal.js +73 -110
- package/esm/node.js +2 -7
- package/esm/parse.js +12 -19
- package/esm/patch-parser.js +10 -30
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +63 -147
- package/esm/rdfaparser.js +794 -997
- package/esm/rdfxmlparser.js +347 -461
- package/esm/serialize.js +9 -27
- package/esm/serializer.js +820 -1049
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +54 -85
- package/esm/store.js +830 -1103
- package/esm/types.js +22 -21
- package/esm/update-manager.js +869 -1106
- package/esm/updates-via.js +104 -161
- package/esm/uri.js +9 -53
- package/esm/utils/default-graph-uri.js +3 -2
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +19 -21
- package/esm/utils-js.js +20 -61
- package/esm/utils.js +10 -21
- package/esm/variable.js +32 -78
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +60 -113
- package/lib/class-order.js +1 -2
- package/lib/collection.js +69 -131
- package/lib/convert.js +3 -9
- package/lib/default-graph.js +13 -52
- package/lib/empty.js +8 -43
- package/lib/factories/canonical-data-factory.js +35 -79
- package/lib/factories/extended-term-factory.js +18 -32
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +1 -4
- package/lib/factories/rdflib-data-factory.js +9 -23
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +1370 -1843
- package/lib/formula.js +640 -855
- package/lib/index.js +66 -152
- package/lib/jsonldparser.js +23 -53
- package/lib/jsonparser.js +1 -10
- package/lib/lists.js +55 -112
- package/lib/literal.js +120 -195
- package/lib/log.d.ts +0 -6
- package/lib/log.js +7 -8
- package/lib/n3parser.js +1030 -1436
- package/lib/named-node.js +69 -126
- package/lib/namespace.js +2 -7
- package/lib/node-internal.js +74 -107
- package/lib/node.js +2 -12
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +12 -32
- package/lib/patch-parser.js +11 -34
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +62 -167
- package/lib/rdfaparser.js +796 -1009
- package/lib/rdfxmlparser.js +349 -466
- package/lib/serialize.js +11 -37
- package/lib/serializer.js +823 -1064
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +55 -91
- package/lib/store.d.ts +1 -1
- package/lib/store.js +850 -1112
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +23 -23
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +865 -1103
- package/lib/updates-via.js +105 -164
- package/lib/uri.js +8 -61
- package/lib/utils/default-graph-uri.js +3 -5
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +19 -40
- package/lib/utils-js.js +23 -88
- package/lib/utils.js +10 -27
- package/lib/variable.js +34 -85
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +2 -6
- package/package.json +35 -35
- package/src/fetcher.ts +2 -2
- package/src/update-manager.ts +12 -7
- package/changes.txt +0 -59
package/esm/utils-js.js
CHANGED
|
@@ -6,18 +6,18 @@ import { docpart } from './uri';
|
|
|
6
6
|
import log from './log';
|
|
7
7
|
import * as uri from './uri';
|
|
8
8
|
import NamedNode from './named-node';
|
|
9
|
-
|
|
9
|
+
const string = {
|
|
10
10
|
template: stringTemplate
|
|
11
11
|
};
|
|
12
12
|
export { log, uri, string };
|
|
13
13
|
export function mediaTypeClass(mediaType) {
|
|
14
14
|
mediaType = mediaType.split(';')[0].trim(); // remove media type parameters
|
|
15
|
-
|
|
16
15
|
return new NamedNode('http://www.w3.org/ns/iana/media-types/' + mediaType + '#Resource');
|
|
17
16
|
}
|
|
18
17
|
export function linkRelationProperty(relation) {
|
|
19
18
|
return new NamedNode('http://www.w3.org/ns/iana/link-relations/relation#' + relation.trim());
|
|
20
19
|
}
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* Adds callback functionality to an object.
|
|
23
23
|
* Callback functions are indexed by a 'hook' string.
|
|
@@ -26,24 +26,19 @@ export function linkRelationProperty(relation) {
|
|
|
26
26
|
* @param obj {Object}
|
|
27
27
|
* @param callbacks {Array<string>}
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
29
|
export function callbackify(obj, callbacks) {
|
|
31
30
|
obj.callbacks = {};
|
|
32
|
-
|
|
33
31
|
for (var x = callbacks.length - 1; x >= 0; x--) {
|
|
34
32
|
obj.callbacks[callbacks[x]] = [];
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
obj.addHook = function (hook) {
|
|
38
35
|
if (!obj.callbacks[hook]) {
|
|
39
36
|
obj.callbacks[hook] = [];
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
|
|
43
39
|
obj.addCallback = function (hook, func) {
|
|
44
40
|
obj.callbacks[hook].push(func);
|
|
45
41
|
};
|
|
46
|
-
|
|
47
42
|
obj.removeCallback = function (hook, funcName) {
|
|
48
43
|
for (var i = 0; i < obj.callbacks[hook].length; i++) {
|
|
49
44
|
if (obj.callbacks[hook][i].name === funcName) {
|
|
@@ -51,45 +46,39 @@ export function callbackify(obj, callbacks) {
|
|
|
51
46
|
return true;
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
return false;
|
|
56
50
|
};
|
|
57
|
-
|
|
58
51
|
obj.insertCallback = function (hook, func) {
|
|
59
52
|
obj.callbacks[hook].unshift(func);
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
obj.fireCallbacks = function fireCallbacks(hook, args) {
|
|
63
55
|
var newCallbacks = [];
|
|
64
56
|
var replaceCallbacks = [];
|
|
65
57
|
var len = obj.callbacks[hook].length;
|
|
66
58
|
var x;
|
|
67
|
-
|
|
59
|
+
let callback;
|
|
68
60
|
|
|
61
|
+
// log.info('!@$ Firing '+hook+' call back with length'+len)
|
|
69
62
|
for (x = len - 1; x >= 0; x--) {
|
|
70
63
|
// log.info('@@ Firing '+hook+' callback '+ obj.callbacks[hook][x])
|
|
71
64
|
callback = obj.callbacks[hook][x];
|
|
72
|
-
|
|
73
65
|
if (callback && callback.apply(obj, args)) {
|
|
74
66
|
newCallbacks.push(callback);
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
|
|
78
69
|
for (x = newCallbacks.length - 1; x >= 0; x--) {
|
|
79
70
|
replaceCallbacks.push(newCallbacks[x]);
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
for (x = len; x < obj.callbacks[hook].length; x++) {
|
|
83
73
|
replaceCallbacks.push(obj.callbacks[hook][x]);
|
|
84
74
|
}
|
|
85
|
-
|
|
86
75
|
obj.callbacks[hook] = replaceCallbacks;
|
|
87
76
|
};
|
|
88
77
|
}
|
|
78
|
+
|
|
89
79
|
/**
|
|
90
80
|
* Returns a DOM parser based on current runtime environment.
|
|
91
81
|
*/
|
|
92
|
-
|
|
93
82
|
export function DOMParserFactory() {
|
|
94
83
|
if (window.DOMParser) {
|
|
95
84
|
return new DOMParser();
|
|
@@ -98,26 +87,23 @@ export function DOMParserFactory() {
|
|
|
98
87
|
} else {
|
|
99
88
|
return false;
|
|
100
89
|
}
|
|
101
|
-
}
|
|
90
|
+
}
|
|
102
91
|
|
|
92
|
+
// From https://github.com/linkeddata/dokieli
|
|
103
93
|
export function domToString(node, options) {
|
|
104
94
|
options = options || {};
|
|
105
95
|
var selfClosing = [];
|
|
106
|
-
|
|
107
96
|
if (options && options.selfClosing) {
|
|
108
97
|
options.selfClosing.split(' ').forEach(function (n) {
|
|
109
98
|
selfClosing[n] = true;
|
|
110
99
|
});
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
var skipAttributes = [];
|
|
114
|
-
|
|
115
102
|
if (options && options.skipAttributes) {
|
|
116
103
|
options.skipAttributes.split(' ').forEach(function (n) {
|
|
117
104
|
skipAttributes[n] = true;
|
|
118
105
|
});
|
|
119
106
|
}
|
|
120
|
-
|
|
121
107
|
return dumpNode(node, options, selfClosing, skipAttributes);
|
|
122
108
|
}
|
|
123
109
|
export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
@@ -125,7 +111,6 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
125
111
|
var out = '';
|
|
126
112
|
var noEsc = [false];
|
|
127
113
|
if (typeof node.nodeType === 'undefined') return out;
|
|
128
|
-
|
|
129
114
|
if (node.nodeType === 1) {
|
|
130
115
|
if (node.hasAttribute('class') && options && options.classWithChildText && node.matches(options.classWithChildText.class)) {
|
|
131
116
|
out += node.querySelector(options.classWithChildText.element).textContent;
|
|
@@ -133,43 +118,33 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
133
118
|
var ename = node.nodeName.toLowerCase();
|
|
134
119
|
out += '<' + ename;
|
|
135
120
|
var attrList = [];
|
|
136
|
-
|
|
137
121
|
for (i = node.attributes.length - 1; i >= 0; i--) {
|
|
138
122
|
var atn = node.attributes[i];
|
|
139
123
|
if (skipAttributes && skipAttributes.length > 0 && skipAttributes[atn.name]) continue;
|
|
140
124
|
if (/^\d+$/.test(atn.name)) continue;
|
|
141
|
-
|
|
142
125
|
if (atn.name === 'class' && options && options.replaceClassItemWith && atn.value.split(' ').indexOf(options.replaceClassItemWith.source) > -1) {
|
|
143
126
|
var re = new RegExp(options.replaceClassItemWith.source, 'g');
|
|
144
127
|
atn.value = atn.value.replace(re, options.replaceClassItemWith.target).trim();
|
|
145
128
|
}
|
|
146
|
-
|
|
147
129
|
if (!(atn.name === 'class' && options && options.skipClassWithValue && options.skipClassWithValue === atn.value)) {
|
|
148
130
|
attrList.push(atn.name + '=\'' + atn.value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, '"') + '\'');
|
|
149
131
|
}
|
|
150
132
|
}
|
|
151
|
-
|
|
152
133
|
if (attrList.length > 0) {
|
|
153
134
|
if (options && options.sortAttributes) {
|
|
154
135
|
attrList.sort(function (a, b) {
|
|
155
136
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
|
156
137
|
});
|
|
157
138
|
}
|
|
158
|
-
|
|
159
139
|
out += ' ' + attrList.join(' ');
|
|
160
140
|
}
|
|
161
|
-
|
|
162
141
|
if (selfClosing && selfClosing.ename) {
|
|
163
142
|
out += ' />';
|
|
164
143
|
} else {
|
|
165
144
|
out += '>';
|
|
166
145
|
out += ename === 'html' ? '\n ' : '';
|
|
167
146
|
noEsc.push(ename === 'style' || ename === 'script');
|
|
168
|
-
|
|
169
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
170
|
-
out += dumpNode(node.childNodes[i]);
|
|
171
|
-
}
|
|
172
|
-
|
|
147
|
+
for (i = 0; i < node.childNodes.length; i++) out += dumpNode(node.childNodes[i]);
|
|
173
148
|
noEsc.pop();
|
|
174
149
|
out += ename === 'body' ? '</' + ename + '>' + '\n' : '</' + ename + '>';
|
|
175
150
|
}
|
|
@@ -185,7 +160,6 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
185
160
|
console.log('Warning; Cannot handle serialising nodes of type: ' + node.nodeType);
|
|
186
161
|
console.log(node);
|
|
187
162
|
}
|
|
188
|
-
|
|
189
163
|
return out;
|
|
190
164
|
}
|
|
191
165
|
export function dtstamp() {
|
|
@@ -203,16 +177,15 @@ export function dtstamp() {
|
|
|
203
177
|
if (second < 10) second = '0' + second;
|
|
204
178
|
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + 'Z';
|
|
205
179
|
}
|
|
180
|
+
|
|
206
181
|
/**
|
|
207
182
|
* Compares statements (heavy comparison for repeatable canonical ordering)
|
|
208
183
|
*/
|
|
209
|
-
|
|
210
184
|
export function heavyCompare(x, y, g, uriMap) {
|
|
211
|
-
var nonBlank = function
|
|
185
|
+
var nonBlank = function (x) {
|
|
212
186
|
return x.termType === 'BlankNode' ? null : x;
|
|
213
187
|
};
|
|
214
|
-
|
|
215
|
-
var signature = function signature(x) {
|
|
188
|
+
var signature = function (x) {
|
|
216
189
|
var lis = g.statementsMatching(x).map(function (st) {
|
|
217
190
|
return '' + nonBlank(st.subject) + ' ' + nonBlank(st.predicate) + ' ' + nonBlank(st.object);
|
|
218
191
|
}).concat(g.statementsMatching(undefined, undefined, x).map(function (st) {
|
|
@@ -221,12 +194,9 @@ export function heavyCompare(x, y, g, uriMap) {
|
|
|
221
194
|
lis.sort();
|
|
222
195
|
return lis.join('\n');
|
|
223
196
|
};
|
|
224
|
-
|
|
225
|
-
var comparison = Object.prototype.hasOwnProperty.call(g, "compareTerms") ? g.compareTerms(x, y) : x.compareTerm(y);
|
|
226
|
-
|
|
197
|
+
const comparison = Object.prototype.hasOwnProperty.call(g, "compareTerms") ? g.compareTerms(x, y) : x.compareTerm(y);
|
|
227
198
|
if (x.termType === 'BlankNode' && y.termType === 'BlankNode') {
|
|
228
199
|
if (comparison === 0) return 0; // Same
|
|
229
|
-
|
|
230
200
|
if (signature(x) > signature(y)) return +1;
|
|
231
201
|
if (signature(x) < signature(y)) return -1;
|
|
232
202
|
return comparison; // Too bad -- this order not canonical.
|
|
@@ -235,33 +205,31 @@ export function heavyCompare(x, y, g, uriMap) {
|
|
|
235
205
|
if (uriMap && x.uri && y.uri) {
|
|
236
206
|
return (uriMap[x.uri] || x.uri).localeCompare(uriMap[y.uri] || y.uri);
|
|
237
207
|
}
|
|
238
|
-
|
|
239
208
|
return comparison;
|
|
240
209
|
}
|
|
241
210
|
}
|
|
242
211
|
export function heavyCompareSPO(x, y, g, uriMap) {
|
|
243
212
|
return heavyCompare(x.subject, y.subject, g, uriMap) || heavyCompare(x.predicate, y.predicate, g, uriMap) || heavyCompare(x.object, y.object, g, uriMap);
|
|
244
213
|
}
|
|
214
|
+
|
|
245
215
|
/**
|
|
246
216
|
* Defines a simple debugging function
|
|
247
217
|
* @method output
|
|
248
218
|
* @param o {String}
|
|
249
219
|
*/
|
|
250
|
-
|
|
251
220
|
export function output(o) {
|
|
252
221
|
var k = document.createElement('div');
|
|
253
222
|
k.textContent = o;
|
|
254
223
|
document.body.appendChild(k);
|
|
255
224
|
}
|
|
256
225
|
import { DOMParser } from '@xmldom/xmldom';
|
|
226
|
+
|
|
257
227
|
/**
|
|
258
228
|
* Returns a DOM from parsed XML.
|
|
259
229
|
*/
|
|
260
|
-
|
|
261
230
|
export function parseXML(str, options) {
|
|
262
231
|
var dparser;
|
|
263
232
|
options = options || {};
|
|
264
|
-
|
|
265
233
|
if (typeof module !== 'undefined' && module && module.exports) {
|
|
266
234
|
// Node.js
|
|
267
235
|
var dom = new DOMParser().parseFromString(str, options.contentType || 'application/xhtml+xml');
|
|
@@ -276,10 +244,10 @@ export function parseXML(str, options) {
|
|
|
276
244
|
|
|
277
245
|
return dparser.parseFromString(str, 'application/xml');
|
|
278
246
|
}
|
|
247
|
+
|
|
279
248
|
/**
|
|
280
249
|
* Removes all statements equal to x from a
|
|
281
250
|
*/
|
|
282
|
-
|
|
283
251
|
export function RDFArrayRemove(a, x) {
|
|
284
252
|
for (var i = 0; i < a.length; i++) {
|
|
285
253
|
// TODO: This used to be the following, which didnt always work..why
|
|
@@ -289,60 +257,51 @@ export function RDFArrayRemove(a, x) {
|
|
|
289
257
|
return;
|
|
290
258
|
}
|
|
291
259
|
}
|
|
292
|
-
|
|
293
260
|
throw new Error('RDFArrayRemove: Array did not contain ' + x + ' ' + x.why);
|
|
294
261
|
}
|
|
295
262
|
export function string_startswith(str, pref) {
|
|
296
263
|
// missing library routines
|
|
297
264
|
return str.slice(0, pref.length) === pref;
|
|
298
265
|
}
|
|
266
|
+
|
|
299
267
|
/**
|
|
300
268
|
* C++, python style %s -> subs
|
|
301
269
|
*/
|
|
302
|
-
|
|
303
270
|
function stringTemplate(base, subs) {
|
|
304
271
|
var baseA = base.split('%s');
|
|
305
272
|
var result = '';
|
|
306
|
-
|
|
307
273
|
for (var i = 0; i < subs.length; i++) {
|
|
308
274
|
subs[i] += '';
|
|
309
275
|
result += baseA[i] + subs[i];
|
|
310
276
|
}
|
|
311
|
-
|
|
312
277
|
return result + baseA.slice(subs.length).join();
|
|
313
|
-
}
|
|
278
|
+
}
|
|
314
279
|
|
|
280
|
+
// Stack dump on errors - to pass errors back
|
|
315
281
|
|
|
316
282
|
export function stackString(e) {
|
|
317
283
|
var str = '' + e + '\n';
|
|
318
|
-
|
|
319
284
|
if (!e.stack) {
|
|
320
285
|
return str + 'No stack available.\n';
|
|
321
286
|
}
|
|
322
|
-
|
|
323
287
|
var lines = e.stack.toString().split('\n');
|
|
324
288
|
var toprint = [];
|
|
325
|
-
|
|
326
289
|
for (var i = 0; i < lines.length; i++) {
|
|
327
290
|
var line = lines[i];
|
|
328
|
-
|
|
329
291
|
if (line.indexOf('ecmaunit.js') > -1) {
|
|
330
292
|
// remove useless bit of traceback
|
|
331
293
|
break;
|
|
332
294
|
}
|
|
333
|
-
|
|
334
295
|
if (line.charAt(0) == '(') {
|
|
335
296
|
line = 'function' + line;
|
|
336
297
|
}
|
|
337
|
-
|
|
338
298
|
var chunks = line.split('@');
|
|
339
299
|
toprint.push(chunks);
|
|
340
|
-
}
|
|
341
|
-
|
|
300
|
+
}
|
|
301
|
+
// toprint.reverse(); No - I prefer the latest at the top by the error message -tbl
|
|
342
302
|
|
|
343
303
|
for (var i = 0; i < toprint.length; i++) {
|
|
344
304
|
str += ' ' + toprint[i][1] + '\n ' + toprint[i][0];
|
|
345
305
|
}
|
|
346
|
-
|
|
347
306
|
return str;
|
|
348
307
|
}
|
package/esm/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import log from './log';
|
|
2
2
|
import { docpart } from './uri';
|
|
3
3
|
import { string_startswith } from './utils-js';
|
|
4
|
-
|
|
5
4
|
/** RDF/JS spec Typeguards */
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -10,30 +9,28 @@ import { string_startswith } from './utils-js';
|
|
|
10
9
|
*/
|
|
11
10
|
export function AJAR_handleNewTerm(kb, p, requestedBy) {
|
|
12
11
|
var sf = null;
|
|
13
|
-
|
|
14
12
|
if (typeof kb.fetcher !== 'undefined') {
|
|
15
13
|
sf = kb.fetcher;
|
|
16
14
|
} else {
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
if (p.termType !== 'NamedNode') return;
|
|
21
18
|
var docuri = docpart(p.uri);
|
|
22
19
|
var fixuri;
|
|
23
|
-
|
|
24
20
|
if (p.uri.indexOf('#') < 0) {
|
|
25
21
|
// No hash
|
|
26
22
|
// @@ major hack for dbpedia Categories, which spread indefinitely
|
|
27
23
|
if (string_startswith(p.uri, 'http://dbpedia.org/resource/Category:')) return;
|
|
24
|
+
|
|
28
25
|
/*
|
|
29
26
|
if (string_startswith(p.uri, 'http://xmlns.com/foaf/0.1/')) {
|
|
30
27
|
fixuri = "http://dig.csail.mit.edu/2005/ajar/ajaw/test/foaf"
|
|
31
28
|
// should give HTTP 303 to ontology -- now is :-)
|
|
32
29
|
} else
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
31
|
if (string_startswith(p.uri, 'http://purl.org/dc/elements/1.1/') || string_startswith(p.uri, 'http://purl.org/dc/terms/')) {
|
|
36
|
-
fixuri = 'http://dublincore.org/2005/06/13/dcq';
|
|
32
|
+
fixuri = 'http://dublincore.org/2005/06/13/dcq';
|
|
33
|
+
// dc fetched multiple times
|
|
37
34
|
} else if (string_startswith(p.uri, 'http://xmlns.com/wot/0.1/')) {
|
|
38
35
|
fixuri = 'http://xmlns.com/wot/0.1/index.rdf';
|
|
39
36
|
} else if (string_startswith(p.uri, 'http://web.resource.org/cc/')) {
|
|
@@ -41,28 +38,25 @@ export function AJAR_handleNewTerm(kb, p, requestedBy) {
|
|
|
41
38
|
fixuri = 'http://web.resource.org/cc/schema.rdf';
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
if (fixuri) {
|
|
46
42
|
docuri = fixuri;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
if (sf && sf.getState(docuri) !== 'unrequested') return;
|
|
50
|
-
|
|
51
45
|
if (fixuri) {
|
|
52
46
|
// only give warning once: else happens too often
|
|
53
47
|
log.warn('Assuming server still broken, faking redirect of <' + p.uri + '> to <' + docuri + '>');
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return sf.fetch(docuri, {
|
|
57
50
|
referringTerm: requestedBy
|
|
58
51
|
});
|
|
59
52
|
}
|
|
60
|
-
export
|
|
61
|
-
|
|
53
|
+
export const appliedFactoryMethods = ['blankNode', 'defaultGraph', 'literal', 'namedNode', 'quad', 'variable', 'supports'];
|
|
54
|
+
const rdf = {
|
|
62
55
|
first: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first',
|
|
63
56
|
rest: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',
|
|
64
57
|
nil: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'
|
|
65
58
|
};
|
|
59
|
+
|
|
66
60
|
/**
|
|
67
61
|
* Expands an array of Terms to a set of statements representing the rdf:list.
|
|
68
62
|
* @param rdfFactory - The factory to use
|
|
@@ -70,34 +64,29 @@ var rdf = {
|
|
|
70
64
|
* @param data - The terms to expand into the list.
|
|
71
65
|
* @return The {data} as a set of statements.
|
|
72
66
|
*/
|
|
73
|
-
|
|
74
67
|
export function arrayToStatements(rdfFactory, subject, data) {
|
|
75
|
-
|
|
76
|
-
data.reduce(
|
|
68
|
+
const statements = [];
|
|
69
|
+
data.reduce((id, _listObj, i, listData) => {
|
|
77
70
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.first), listData[i]));
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
let nextNode;
|
|
80
72
|
if (i < listData.length - 1) {
|
|
81
73
|
nextNode = rdfFactory.blankNode();
|
|
82
74
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.rest), nextNode));
|
|
83
75
|
} else {
|
|
84
76
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.rest), rdfFactory.namedNode(rdf.nil)));
|
|
85
77
|
}
|
|
86
|
-
|
|
87
78
|
return nextNode;
|
|
88
79
|
}, subject);
|
|
89
80
|
return statements;
|
|
90
81
|
}
|
|
91
82
|
export function ArrayIndexOf(arr, item) {
|
|
92
|
-
|
|
83
|
+
let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
93
84
|
var length = arr.length;
|
|
94
85
|
if (i < 0) i = length + i;
|
|
95
|
-
|
|
96
86
|
for (; i < length; i++) {
|
|
97
87
|
if (arr[i] === item) {
|
|
98
88
|
return i;
|
|
99
89
|
}
|
|
100
90
|
}
|
|
101
|
-
|
|
102
91
|
return -1;
|
|
103
92
|
}
|
package/esm/variable.js
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
2
|
import ClassOrder from './class-order';
|
|
14
3
|
import Node from './node-internal';
|
|
15
4
|
import { VariableTermType } from './types';
|
|
16
5
|
import * as Uri from './uri';
|
|
17
|
-
|
|
18
6
|
/**
|
|
19
7
|
* Variables are placeholders used in patterns to be matched.
|
|
20
8
|
* In cwm they are symbols which are the formula's list of quantified variables.
|
|
@@ -22,11 +10,7 @@ import * as Uri from './uri';
|
|
|
22
10
|
* a common special base URI for variables. Their names are uris,
|
|
23
11
|
* but the ? notation has an implicit base uri of 'varid:'
|
|
24
12
|
*/
|
|
25
|
-
|
|
26
|
-
_inherits(Variable, _Node);
|
|
27
|
-
|
|
28
|
-
var _super = _createSuper(Variable);
|
|
29
|
-
|
|
13
|
+
export default class Variable extends Node {
|
|
30
14
|
/** The base string for a variable's name */
|
|
31
15
|
|
|
32
16
|
/** The unique identifier of this variable */
|
|
@@ -35,67 +19,37 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
35
19
|
* Initializes this variable
|
|
36
20
|
* @param name The variable's name
|
|
37
21
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_defineProperty(_assertThisInitialized(_this), "base", 'varid:');
|
|
50
|
-
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Variable);
|
|
52
|
-
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "uri", void 0);
|
|
56
|
-
|
|
57
|
-
_this.base = 'varid:';
|
|
58
|
-
_this.uri = Uri.join(name, _this.base);
|
|
59
|
-
return _this;
|
|
22
|
+
constructor() {
|
|
23
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
24
|
+
super(name);
|
|
25
|
+
_defineProperty(this, "termType", VariableTermType);
|
|
26
|
+
_defineProperty(this, "base", 'varid:');
|
|
27
|
+
_defineProperty(this, "classOrder", ClassOrder.Variable);
|
|
28
|
+
_defineProperty(this, "isVar", 1);
|
|
29
|
+
_defineProperty(this, "uri", void 0);
|
|
30
|
+
this.base = 'varid:';
|
|
31
|
+
this.uri = Uri.join(name, this.base);
|
|
60
32
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
value: function equals(other) {
|
|
65
|
-
if (!other) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return this.termType === other.termType && this.value === other.value;
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "hashString",
|
|
73
|
-
value: function hashString() {
|
|
74
|
-
return this.toString();
|
|
33
|
+
equals(other) {
|
|
34
|
+
if (!other) {
|
|
35
|
+
return false;
|
|
75
36
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return "?".concat(variable.uri.slice(variable.base.length));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return "?".concat(variable.uri);
|
|
37
|
+
return this.termType === other.termType && this.value === other.value;
|
|
38
|
+
}
|
|
39
|
+
hashString() {
|
|
40
|
+
return this.toString();
|
|
41
|
+
}
|
|
42
|
+
substitute(bindings) {
|
|
43
|
+
var ref;
|
|
44
|
+
return (ref = bindings[this.toNT()]) != null ? ref : this;
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
return Variable.toString(this);
|
|
48
|
+
}
|
|
49
|
+
static toString(variable) {
|
|
50
|
+
if (variable.uri.slice(0, variable.base.length) === variable.base) {
|
|
51
|
+
return `?${variable.uri.slice(variable.base.length)}`;
|
|
95
52
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}(Node);
|
|
100
|
-
|
|
101
|
-
export { Variable as default };
|
|
53
|
+
return `?${variable.uri}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
package/esm/xsd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import CanonicalDataFactory from "./factories/canonical-data-factory";
|
|
2
2
|
export function createXSD() {
|
|
3
|
-
|
|
3
|
+
let localFactory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CanonicalDataFactory;
|
|
4
4
|
return {
|
|
5
5
|
boolean: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),
|
|
6
6
|
dateTime: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),
|
|
@@ -11,5 +11,5 @@ export function createXSD() {
|
|
|
11
11
|
string: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#string")
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const defaultXSD = createXSD(CanonicalDataFactory);
|
|
15
15
|
export default defaultXSD;
|