rdflib 2.2.21 → 2.2.22-0de51c50
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 +13 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +3 -27
- package/esm/collection.js +7 -29
- package/esm/default-graph.js +1 -15
- package/esm/empty.js +0 -13
- package/esm/factories/canonical-data-factory.js +5 -40
- package/esm/factories/extended-term-factory.js +0 -11
- package/esm/factories/factory-types.js +2 -1
- package/esm/factories/rdflib-data-factory.js +0 -8
- package/esm/fetcher.js +257 -481
- package/esm/formula.js +43 -142
- package/esm/index.js +19 -36
- package/esm/jsonldparser.js +20 -29
- package/esm/jsonparser.js +0 -7
- package/esm/lists.js +18 -33
- package/esm/literal.js +10 -42
- package/esm/n3parser.js +38 -351
- package/esm/named-node.js +8 -27
- package/esm/namespace.js +0 -1
- package/esm/node-internal.js +11 -24
- package/esm/node.js +1 -6
- package/esm/parse.js +10 -17
- package/esm/patch-parser.js +9 -29
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +50 -133
- package/esm/rdfaparser.js +72 -210
- package/esm/rdfxmlparser.js +31 -128
- package/esm/serialize.js +8 -33
- package/esm/serializer.js +122 -286
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +8 -19
- package/esm/store.js +109 -280
- package/esm/types.js +3 -2
- package/esm/update-manager.js +110 -246
- package/esm/updates-via.js +0 -27
- package/esm/uri.js +6 -50
- package/esm/utils/default-graph-uri.js +1 -0
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +15 -16
- package/esm/utils-js.js +16 -57
- package/esm/utils.js +4 -15
- package/esm/variable.js +0 -20
- package/lib/blank-node.js +3 -28
- package/lib/class-order.js +0 -1
- package/lib/collection.js +7 -34
- package/lib/default-graph.js +0 -20
- package/lib/empty.js +0 -18
- package/lib/factories/canonical-data-factory.js +4 -51
- package/lib/factories/extended-term-factory.js +0 -18
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +0 -3
- package/lib/factories/rdflib-data-factory.js +0 -12
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +258 -470
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +43 -151
- package/lib/index.d.ts +1 -2
- package/lib/index.js +14 -82
- package/lib/jsonldparser.js +19 -33
- package/lib/jsonparser.js +0 -9
- package/lib/lists.js +14 -39
- package/lib/literal.js +10 -49
- package/lib/log.d.ts +0 -6
- package/lib/log.js +0 -1
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +39 -359
- package/lib/named-node.js +7 -35
- package/lib/namespace.js +0 -3
- package/lib/node-internal.js +11 -21
- package/lib/node.js +1 -11
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +8 -27
- package/lib/patch-parser.js +10 -33
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +46 -152
- package/lib/rdfaparser.js +72 -220
- package/lib/rdfxmlparser.js +31 -132
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +8 -43
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +121 -297
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +8 -24
- package/lib/store.d.ts +2 -2
- package/lib/store.js +102 -282
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +3 -3
- package/lib/update-manager.d.ts +2 -2
- package/lib/update-manager.js +110 -254
- package/lib/updates-via.js +0 -30
- package/lib/uri.js +5 -58
- package/lib/utils/default-graph-uri.js +1 -3
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +15 -34
- package/lib/utils-js.js +16 -80
- package/lib/utils.js +4 -21
- package/lib/variable.js +0 -25
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +0 -4
- package/package.json +40 -39
- package/src/fetcher.ts +2 -2
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/n3parser.js +12 -4
- package/src/serialize.ts +4 -11
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +18 -7
- package/changes.txt +0 -59
- package/esm/convert.js +0 -61
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -77
- package/src/convert.js +0 -70
package/esm/rdfaparser.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
// RDFa Parser for rdflib.js
|
|
4
|
+
|
|
4
5
|
// Originally by: Alex Milowski
|
|
5
6
|
// From https://github.com/alexmilowski/green-turtle
|
|
6
7
|
// Converted: timbl 2015-08-25 not yet working
|
|
7
8
|
// Added wrapper: csarven 2016-05-09 working
|
|
9
|
+
|
|
8
10
|
// RDFaProcessor.prototype = new Object() // Was URIResolver
|
|
11
|
+
|
|
9
12
|
// RDFaProcessor.prototype.constructor=RDFaProcessor
|
|
13
|
+
|
|
10
14
|
// options.base = base URI not really an option, shopuld always be set.
|
|
11
15
|
//
|
|
16
|
+
|
|
12
17
|
import BlankNode from './blank-node';
|
|
13
18
|
import Literal from './literal';
|
|
14
19
|
import NamedNode from './named-node';
|
|
15
20
|
import * as Uri from './uri';
|
|
16
21
|
import * as Util from './utils-js';
|
|
17
22
|
import rdf from './factories/canonical-data-factory';
|
|
18
|
-
|
|
19
23
|
if (typeof Node === 'undefined') {
|
|
20
24
|
// @@@@@@ Global. Interface to xmldom.
|
|
21
25
|
var Node = {
|
|
@@ -33,11 +37,9 @@ if (typeof Node === 'undefined') {
|
|
|
33
37
|
NOTATION_NODE: 12
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
|
-
|
|
37
40
|
var RDFaProcessor = /*#__PURE__*/function () {
|
|
38
41
|
function RDFaProcessor(kb, options) {
|
|
39
42
|
_classCallCheck(this, RDFaProcessor);
|
|
40
|
-
|
|
41
43
|
this.options = options || {};
|
|
42
44
|
this.kb = kb;
|
|
43
45
|
this.target = options.target || {
|
|
@@ -46,10 +48,10 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
46
48
|
prefixes: {},
|
|
47
49
|
terms: {}
|
|
48
50
|
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
this.blankNodes = [];
|
|
52
|
-
|
|
51
|
+
};
|
|
52
|
+
// XXX: Added to track bnodes
|
|
53
|
+
this.blankNodes = [];
|
|
54
|
+
// XXX: Added for normalisation
|
|
53
55
|
this.htmlOptions = {
|
|
54
56
|
'selfClosing': 'br img input area base basefont col colgroup source wbr isindex link meta param hr'
|
|
55
57
|
};
|
|
@@ -66,45 +68,38 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
66
68
|
this.finishedHandlers = [];
|
|
67
69
|
this.init();
|
|
68
70
|
}
|
|
69
|
-
|
|
70
71
|
_createClass(RDFaProcessor, [{
|
|
71
72
|
key: "addTriple",
|
|
72
73
|
value: function addTriple(origin, subject, predicate, object) {
|
|
73
74
|
var su, ob, pr, or;
|
|
74
|
-
|
|
75
75
|
if (typeof subject === 'undefined') {
|
|
76
76
|
su = rdf.namedNode(this.options.base);
|
|
77
77
|
} else {
|
|
78
78
|
su = this.toRDFNodeObject(subject);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
80
|
pr = this.toRDFNodeObject(predicate);
|
|
82
81
|
ob = this.toRDFNodeObject(object);
|
|
83
|
-
or = rdf.namedNode(this.options.base);
|
|
84
|
-
|
|
82
|
+
or = rdf.namedNode(this.options.base);
|
|
83
|
+
// console.log('Adding { ' + su + ' ' + pr + ' ' + ob + ' ' + or + ' }')
|
|
85
84
|
this.kb.add(su, pr, ob, or);
|
|
86
85
|
}
|
|
87
86
|
}, {
|
|
88
87
|
key: "ancestorPath",
|
|
89
88
|
value: function ancestorPath(node) {
|
|
90
89
|
var path = '';
|
|
91
|
-
|
|
92
90
|
while (node && node.nodeType !== Node.DOCUMENT_NODE) {
|
|
93
91
|
path = '/' + node.localName + path;
|
|
94
92
|
node = node.parentNode;
|
|
95
93
|
}
|
|
96
|
-
|
|
97
94
|
return path;
|
|
98
95
|
}
|
|
99
96
|
}, {
|
|
100
97
|
key: "copyMappings",
|
|
101
98
|
value: function copyMappings(mappings) {
|
|
102
99
|
var newMappings = {};
|
|
103
|
-
|
|
104
100
|
for (var k in mappings) {
|
|
105
101
|
newMappings[k] = mappings[k];
|
|
106
102
|
}
|
|
107
|
-
|
|
108
103
|
return newMappings;
|
|
109
104
|
}
|
|
110
105
|
}, {
|
|
@@ -116,13 +111,11 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
116
111
|
for (var i = 0; i < RDFaProcessor.dateTimeTypes.length; i++) {
|
|
117
112
|
// console.log("Checking "+value+" against "+RDFaProcessor.dateTimeTypes[i].type)
|
|
118
113
|
var matched = RDFaProcessor.dateTimeTypes[i].pattern.exec(value);
|
|
119
|
-
|
|
120
114
|
if (matched && matched[0].length === value.length) {
|
|
121
115
|
// console.log("Matched!")
|
|
122
116
|
return RDFaProcessor.dateTimeTypes[i].type;
|
|
123
117
|
}
|
|
124
118
|
}
|
|
125
|
-
|
|
126
119
|
return null;
|
|
127
120
|
}
|
|
128
121
|
}, {
|
|
@@ -142,10 +135,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
142
135
|
value: function parseCURIE(value, prefixes, base) {
|
|
143
136
|
var colon = value.indexOf(':');
|
|
144
137
|
var uri;
|
|
145
|
-
|
|
146
138
|
if (colon >= 0) {
|
|
147
139
|
var prefix = value.substring(0, colon);
|
|
148
|
-
|
|
149
140
|
if (prefix === '') {
|
|
150
141
|
// default prefix
|
|
151
142
|
uri = prefixes[''];
|
|
@@ -155,24 +146,20 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
155
146
|
return '_:' + value.substring(colon + 1);
|
|
156
147
|
} else if (RDFaProcessor.NCNAME.test(prefix)) {
|
|
157
148
|
uri = prefixes[prefix];
|
|
158
|
-
|
|
159
149
|
if (uri) {
|
|
160
150
|
return uri + value.substring(colon + 1);
|
|
161
151
|
}
|
|
162
152
|
}
|
|
163
153
|
}
|
|
164
|
-
|
|
165
154
|
return null;
|
|
166
155
|
}
|
|
167
156
|
}, {
|
|
168
157
|
key: "parseCURIEOrURI",
|
|
169
158
|
value: function parseCURIEOrURI(value, prefixes, base) {
|
|
170
159
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
171
|
-
|
|
172
160
|
if (curie) {
|
|
173
161
|
return curie;
|
|
174
162
|
}
|
|
175
|
-
|
|
176
163
|
return this.resolveAndNormalize(base, value);
|
|
177
164
|
}
|
|
178
165
|
}, {
|
|
@@ -181,21 +168,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
181
168
|
if (value === '') {
|
|
182
169
|
return null;
|
|
183
170
|
}
|
|
184
|
-
|
|
185
171
|
var predicate = this.parseTermOrCURIEOrAbsURI(value, defaultVocabulary, ignoreTerms ? null : terms, prefixes, base);
|
|
186
|
-
|
|
187
172
|
if (predicate && predicate.indexOf('_:') === 0) {
|
|
188
173
|
return null;
|
|
189
174
|
}
|
|
190
|
-
|
|
191
175
|
return predicate;
|
|
192
176
|
}
|
|
193
177
|
}, {
|
|
194
178
|
key: "parsePrefixMappings",
|
|
195
179
|
value: function parsePrefixMappings(str, target) {
|
|
196
180
|
var values = this.tokenize(str);
|
|
197
|
-
var prefix = null;
|
|
198
|
-
|
|
181
|
+
var prefix = null;
|
|
182
|
+
// var uri = null
|
|
199
183
|
for (var i = 0; i < values.length; i++) {
|
|
200
184
|
if (values[i][values[i].length - 1] === ':') {
|
|
201
185
|
prefix = values[i].substring(0, values[i].length - 1);
|
|
@@ -209,20 +193,16 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
209
193
|
key: "parseSafeCURIEOrCURIEOrURI",
|
|
210
194
|
value: function parseSafeCURIEOrCURIEOrURI(value, prefixes, base) {
|
|
211
195
|
value = this.trim(value);
|
|
212
|
-
|
|
213
196
|
if (value.charAt(0) === '[' && value.charAt(value.length - 1) === ']') {
|
|
214
197
|
value = value.substring(1, value.length - 1);
|
|
215
198
|
value = value.trim(value);
|
|
216
|
-
|
|
217
199
|
if (value.length === 0) {
|
|
218
200
|
return null;
|
|
219
201
|
}
|
|
220
|
-
|
|
221
202
|
if (value === '_:') {
|
|
222
203
|
// the one node
|
|
223
204
|
return this.theOne;
|
|
224
205
|
}
|
|
225
|
-
|
|
226
206
|
return this.parseCURIE(value, prefixes, base);
|
|
227
207
|
} else {
|
|
228
208
|
return this.parseCURIEOrURI(value, prefixes, base);
|
|
@@ -234,32 +214,25 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
234
214
|
// alert("Parsing "+value+" with default vocab "+defaultVocabulary)
|
|
235
215
|
value = this.trim(value);
|
|
236
216
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
237
|
-
|
|
238
217
|
if (curie) {
|
|
239
218
|
return curie;
|
|
240
219
|
} else if (terms) {
|
|
241
220
|
if (defaultVocabulary && !this.absURIRE.exec(value)) {
|
|
242
221
|
return defaultVocabulary + value;
|
|
243
222
|
}
|
|
244
|
-
|
|
245
223
|
var term = terms[value];
|
|
246
|
-
|
|
247
224
|
if (term) {
|
|
248
225
|
return term;
|
|
249
226
|
}
|
|
250
|
-
|
|
251
227
|
var lcvalue = value.toLowerCase();
|
|
252
228
|
term = terms[lcvalue];
|
|
253
|
-
|
|
254
229
|
if (term) {
|
|
255
230
|
return term;
|
|
256
231
|
}
|
|
257
232
|
}
|
|
258
|
-
|
|
259
233
|
if (this.absURIRE.exec(value)) {
|
|
260
234
|
return this.resolveAndNormalize(base, value);
|
|
261
235
|
}
|
|
262
|
-
|
|
263
236
|
return null;
|
|
264
237
|
}
|
|
265
238
|
}, {
|
|
@@ -268,28 +241,22 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
268
241
|
// alert("Parsing "+value+" with default vocab "+defaultVocabulary)
|
|
269
242
|
value = this.trim(value);
|
|
270
243
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
271
|
-
|
|
272
244
|
if (curie) {
|
|
273
245
|
return curie;
|
|
274
246
|
} else {
|
|
275
247
|
var term = terms[value];
|
|
276
|
-
|
|
277
248
|
if (term) {
|
|
278
249
|
return term;
|
|
279
250
|
}
|
|
280
|
-
|
|
281
251
|
var lcvalue = value.toLowerCase();
|
|
282
252
|
term = terms[lcvalue];
|
|
283
|
-
|
|
284
253
|
if (term) {
|
|
285
254
|
return term;
|
|
286
255
|
}
|
|
287
|
-
|
|
288
256
|
if (defaultVocabulary && !this.absURIRE.exec(value)) {
|
|
289
257
|
return defaultVocabulary + value;
|
|
290
258
|
}
|
|
291
259
|
}
|
|
292
|
-
|
|
293
260
|
return this.resolveAndNormalize(base, value);
|
|
294
261
|
}
|
|
295
262
|
}, {
|
|
@@ -306,7 +273,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
306
273
|
} */
|
|
307
274
|
options = options || {};
|
|
308
275
|
var base;
|
|
309
|
-
|
|
310
276
|
if (node.nodeType === Node.DOCUMENT_NODE) {
|
|
311
277
|
if (node.baseURI && !options.baseURI) {
|
|
312
278
|
options.baseURI = node.baseURI; // be defensive as DOM implementations vary
|
|
@@ -314,56 +280,44 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
314
280
|
|
|
315
281
|
base = node.baseURI;
|
|
316
282
|
node = node.documentElement;
|
|
317
|
-
|
|
318
283
|
if (!node.baseURI) {
|
|
319
284
|
node.baseURI = base;
|
|
320
285
|
}
|
|
321
|
-
|
|
322
286
|
this.setContext(node);
|
|
323
287
|
} else if (node.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
324
288
|
this.setContext(node);
|
|
325
289
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
290
|
+
var queue = [];
|
|
291
|
+
// Fix for Firefox that includes the hash in the base URI
|
|
329
292
|
var removeHash = function removeHash(baseURI) {
|
|
330
293
|
// Fix for undefined baseURI property
|
|
331
294
|
if (!baseURI && options && options.baseURI) {
|
|
332
295
|
return options.baseURI;
|
|
333
296
|
}
|
|
334
|
-
|
|
335
297
|
var hash = baseURI.indexOf('#');
|
|
336
|
-
|
|
337
298
|
if (hash >= 0) {
|
|
338
299
|
baseURI = baseURI.substring(0, hash);
|
|
339
300
|
}
|
|
340
|
-
|
|
341
301
|
if (options && options.baseURIMap) {
|
|
342
302
|
baseURI = options.baseURIMap(baseURI);
|
|
343
303
|
}
|
|
344
|
-
|
|
345
304
|
return baseURI;
|
|
346
305
|
};
|
|
347
|
-
|
|
348
306
|
queue.push({
|
|
349
307
|
current: node,
|
|
350
308
|
context: this.push(null, removeHash(node.baseURI))
|
|
351
309
|
});
|
|
352
|
-
|
|
353
310
|
while (queue.length > 0) {
|
|
354
311
|
var item = queue.shift();
|
|
355
|
-
|
|
356
312
|
if (item.parent) {
|
|
357
313
|
// Sequence Step 14: list triple generation
|
|
358
314
|
if (item.context.parent && item.context.parent.listMapping === item.listMapping) {
|
|
359
315
|
// Skip a child context with exactly the same mapping
|
|
360
316
|
continue;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
317
|
+
}
|
|
318
|
+
// console.log("Generating lists for "+item.subject+", tag "+item.parent.localName)
|
|
364
319
|
for (var _predicate in item.listMapping) {
|
|
365
320
|
var list = item.listMapping[_predicate];
|
|
366
|
-
|
|
367
321
|
if (list.length === 0) {
|
|
368
322
|
this.addTriple(item.parent, item.subject, _predicate, {
|
|
369
323
|
type: RDFaProcessor.objectURI,
|
|
@@ -371,11 +325,10 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
371
325
|
});
|
|
372
326
|
continue;
|
|
373
327
|
}
|
|
374
|
-
|
|
375
328
|
var bnodes = [];
|
|
376
|
-
|
|
377
329
|
for (var _i = 0; _i < list.length; _i++) {
|
|
378
|
-
bnodes.push(this.newBlankNode());
|
|
330
|
+
bnodes.push(this.newBlankNode());
|
|
331
|
+
// this.newSubject(item.parent,bnodes[i])
|
|
379
332
|
}
|
|
380
333
|
|
|
381
334
|
for (var _i2 = 0; _i2 < bnodes.length; _i2++) {
|
|
@@ -385,20 +338,17 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
385
338
|
value: _i2 + 1 < bnodes.length ? bnodes[_i2 + 1] : 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'
|
|
386
339
|
});
|
|
387
340
|
}
|
|
388
|
-
|
|
389
341
|
this.addTriple(item.parent, item.subject, _predicate, {
|
|
390
342
|
type: RDFaProcessor.objectURI,
|
|
391
343
|
value: bnodes[0]
|
|
392
344
|
});
|
|
393
345
|
}
|
|
394
|
-
|
|
395
346
|
continue;
|
|
396
347
|
}
|
|
397
|
-
|
|
398
348
|
var current = item.current;
|
|
399
|
-
var context = item.context;
|
|
349
|
+
var context = item.context;
|
|
350
|
+
// console.log("Tag: "+current.localName+", listMapping="+JSON.stringify(context.listMapping))
|
|
400
351
|
// Sequence Step 1
|
|
401
|
-
|
|
402
352
|
var skip = false;
|
|
403
353
|
var newSubject = null;
|
|
404
354
|
var currentObjectResource = null;
|
|
@@ -409,20 +359,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
409
359
|
var listMapping = context.listMapping;
|
|
410
360
|
var listMappingDifferent = !context.parent;
|
|
411
361
|
var language = context.language;
|
|
412
|
-
var vocabulary = context.vocabulary;
|
|
413
|
-
|
|
362
|
+
var vocabulary = context.vocabulary;
|
|
363
|
+
// TODO: the "base" element may be used for HTML+RDFa 1.1
|
|
414
364
|
base = this.parseURI(removeHash(current.baseURI));
|
|
415
|
-
current.item = null;
|
|
416
|
-
|
|
365
|
+
current.item = null;
|
|
366
|
+
// Sequence Step 2: set the default vocabulary
|
|
417
367
|
var vocabAtt = current.getAttributeNode('vocab');
|
|
418
|
-
|
|
419
368
|
if (vocabAtt) {
|
|
420
369
|
var value = this.trim(vocabAtt.value);
|
|
421
|
-
|
|
422
370
|
if (value.length > 0) {
|
|
423
371
|
vocabulary = value;
|
|
424
|
-
var baseSubject = base.spec;
|
|
425
|
-
|
|
372
|
+
var baseSubject = base.spec;
|
|
373
|
+
// this.newSubject(current,baseSubject)
|
|
426
374
|
this.addTriple(current, baseSubject, 'http://www.w3.org/ns/rdfa#usesVocabulary', {
|
|
427
375
|
type: RDFaProcessor.objectURI,
|
|
428
376
|
value: vocabulary
|
|
@@ -430,55 +378,45 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
430
378
|
} else {
|
|
431
379
|
vocabulary = this.vocabulary;
|
|
432
380
|
}
|
|
433
|
-
}
|
|
381
|
+
}
|
|
382
|
+
// Sequence Step 3: IRI mappings
|
|
434
383
|
// handle xmlns attributes
|
|
435
|
-
|
|
436
|
-
|
|
437
384
|
for (var i = 0; i < current.attributes.length; i++) {
|
|
438
|
-
var att = current.attributes[i];
|
|
439
|
-
|
|
385
|
+
var att = current.attributes[i];
|
|
386
|
+
// if (att.namespaceURI=="http://www.w3.org/2000/xmlns/") {
|
|
440
387
|
if (att.nodeName.charAt(0) === 'x' && att.nodeName.indexOf('xmlns:') === 0) {
|
|
441
388
|
if (!prefixesCopied) {
|
|
442
389
|
prefixes = this.copyMappings(prefixes);
|
|
443
390
|
prefixesCopied = true;
|
|
444
391
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
392
|
+
var prefix = att.nodeName.substring(6);
|
|
393
|
+
// TODO: resolve relative?
|
|
448
394
|
var ref = RDFaProcessor.trim(att.value);
|
|
449
395
|
prefixes[prefix] = this.options.base ? Uri.join(ref, this.options.base) : ref;
|
|
450
396
|
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
397
|
+
}
|
|
398
|
+
// Handle prefix mappings (@prefix)
|
|
454
399
|
var prefixAtt = current.getAttributeNode('prefix');
|
|
455
|
-
|
|
456
400
|
if (prefixAtt) {
|
|
457
401
|
if (!prefixesCopied) {
|
|
458
402
|
prefixes = this.copyMappings(prefixes);
|
|
459
403
|
prefixesCopied = true;
|
|
460
404
|
}
|
|
461
|
-
|
|
462
405
|
this.parsePrefixMappings(prefixAtt.value, prefixes);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
406
|
+
}
|
|
407
|
+
// Sequence Step 4: language
|
|
466
408
|
var xmlLangAtt = null;
|
|
467
|
-
|
|
468
409
|
for (var _i3 = 0; !xmlLangAtt && _i3 < this.langAttributes.length; _i3++) {
|
|
469
410
|
xmlLangAtt = current.getAttributeNodeNS(this.langAttributes[_i3].namespaceURI, this.langAttributes[_i3].localName);
|
|
470
411
|
}
|
|
471
|
-
|
|
472
412
|
if (xmlLangAtt) {
|
|
473
413
|
var _value = RDFaProcessor.trim(xmlLangAtt.value);
|
|
474
|
-
|
|
475
414
|
if (_value.length > 0) {
|
|
476
415
|
language = _value;
|
|
477
416
|
} else {
|
|
478
417
|
language = null;
|
|
479
418
|
}
|
|
480
419
|
}
|
|
481
|
-
|
|
482
420
|
var relAtt = current.getAttributeNode('rel');
|
|
483
421
|
var revAtt = current.getAttributeNode('rev');
|
|
484
422
|
var typeofAtt = current.getAttributeNode('typeof');
|
|
@@ -493,54 +431,42 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
493
431
|
var inlistAtt = current.getAttributeNode('inlist');
|
|
494
432
|
var relAttPredicates = [];
|
|
495
433
|
var predicate, values;
|
|
496
|
-
|
|
497
434
|
if (relAtt) {
|
|
498
435
|
values = this.tokenize(relAtt.value);
|
|
499
|
-
|
|
500
436
|
for (var _i4 = 0; _i4 < values.length; _i4++) {
|
|
501
437
|
predicate = this.parsePredicate(values[_i4], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt !== null);
|
|
502
|
-
|
|
503
438
|
if (predicate) {
|
|
504
439
|
relAttPredicates.push(predicate);
|
|
505
440
|
}
|
|
506
441
|
}
|
|
507
442
|
}
|
|
508
|
-
|
|
509
443
|
var revAttPredicates = [];
|
|
510
|
-
|
|
511
444
|
if (revAtt) {
|
|
512
445
|
values = this.tokenize(revAtt.value);
|
|
513
|
-
|
|
514
446
|
for (var _i5 = 0; _i5 < values.length; _i5++) {
|
|
515
447
|
predicate = this.parsePredicate(values[_i5], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt);
|
|
516
|
-
|
|
517
448
|
if (predicate) {
|
|
518
449
|
revAttPredicates.push(predicate);
|
|
519
450
|
}
|
|
520
451
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
452
|
+
}
|
|
453
|
+
// Section 3.1, bullet 7
|
|
524
454
|
if (this.inHTMLMode && (relAtt || revAtt) && propertyAtt) {
|
|
525
455
|
if (relAttPredicates.length === 0) {
|
|
526
456
|
relAtt = null;
|
|
527
457
|
}
|
|
528
|
-
|
|
529
458
|
if (revAttPredicates.length === 0) {
|
|
530
459
|
revAtt = null;
|
|
531
460
|
}
|
|
532
461
|
}
|
|
533
|
-
|
|
534
462
|
if (relAtt || revAtt) {
|
|
535
463
|
// Sequence Step 6: establish new subject and value
|
|
536
464
|
if (aboutAtt) {
|
|
537
465
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
538
466
|
}
|
|
539
|
-
|
|
540
467
|
if (typeofAtt) {
|
|
541
468
|
typedResource = newSubject;
|
|
542
469
|
}
|
|
543
|
-
|
|
544
470
|
if (!newSubject) {
|
|
545
471
|
if (current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
546
472
|
newSubject = removeHash(current.baseURI);
|
|
@@ -549,11 +475,9 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
549
475
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
550
476
|
}
|
|
551
477
|
}
|
|
552
|
-
|
|
553
478
|
if (resourceAtt) {
|
|
554
479
|
currentObjectResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
555
480
|
}
|
|
556
|
-
|
|
557
481
|
if (!currentObjectResource) {
|
|
558
482
|
if (hrefAtt) {
|
|
559
483
|
currentObjectResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
@@ -563,7 +487,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
563
487
|
currentObjectResource = this.newBlankNode();
|
|
564
488
|
}
|
|
565
489
|
}
|
|
566
|
-
|
|
567
490
|
if (typeofAtt && !aboutAtt && this.inXHTMLMode && (current.localName === 'head' || current.localName === 'body')) {
|
|
568
491
|
typedResource = newSubject;
|
|
569
492
|
} else if (typeofAtt && !aboutAtt) {
|
|
@@ -573,15 +496,12 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
573
496
|
// Sequence Step 5.1: establish a new subject
|
|
574
497
|
if (aboutAtt) {
|
|
575
498
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
576
|
-
|
|
577
499
|
if (typeofAtt) {
|
|
578
500
|
typedResource = newSubject;
|
|
579
501
|
}
|
|
580
502
|
}
|
|
581
|
-
|
|
582
503
|
if (!newSubject && current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
583
504
|
newSubject = removeHash(current.baseURI);
|
|
584
|
-
|
|
585
505
|
if (typeofAtt) {
|
|
586
506
|
typedResource = newSubject;
|
|
587
507
|
}
|
|
@@ -589,49 +509,39 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
589
509
|
// TODO: Verify: If the xml:base has been set and the parentObject is the baseURI of the parent, then the subject needs to be the new base URI
|
|
590
510
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
591
511
|
}
|
|
592
|
-
|
|
593
512
|
if (typeofAtt && !typedResource) {
|
|
594
513
|
if (resourceAtt) {
|
|
595
514
|
typedResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
596
515
|
}
|
|
597
|
-
|
|
598
516
|
if (!typedResource && hrefAtt) {
|
|
599
517
|
typedResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
600
518
|
}
|
|
601
|
-
|
|
602
519
|
if (!typedResource && srcAtt) {
|
|
603
520
|
typedResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
604
521
|
}
|
|
605
|
-
|
|
606
522
|
if (!typedResource && (this.inXHTMLMode || this.inHTMLMode) && (current.localName === 'head' || current.localName === 'body')) {
|
|
607
523
|
typedResource = newSubject;
|
|
608
524
|
}
|
|
609
|
-
|
|
610
525
|
if (!typedResource) {
|
|
611
526
|
typedResource = this.newBlankNode();
|
|
612
527
|
}
|
|
613
|
-
|
|
614
528
|
currentObjectResource = typedResource;
|
|
615
|
-
}
|
|
616
|
-
|
|
529
|
+
}
|
|
530
|
+
// console.log(current.localName+", newSubject="+newSubject+", typedResource="+typedResource+", currentObjectResource="+currentObjectResource)
|
|
617
531
|
} else {
|
|
618
532
|
// Sequence Step 5.2: establish a new subject
|
|
619
533
|
if (aboutAtt) {
|
|
620
534
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
621
535
|
}
|
|
622
|
-
|
|
623
536
|
if (!newSubject && resourceAtt) {
|
|
624
537
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
625
538
|
}
|
|
626
|
-
|
|
627
539
|
if (!newSubject && hrefAtt) {
|
|
628
540
|
newSubject = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
629
541
|
}
|
|
630
|
-
|
|
631
542
|
if (!newSubject && srcAtt) {
|
|
632
543
|
newSubject = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
633
544
|
}
|
|
634
|
-
|
|
635
545
|
if (!newSubject) {
|
|
636
546
|
if (current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
637
547
|
newSubject = removeHash(current.baseURI);
|
|
@@ -642,41 +552,33 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
642
552
|
} else if (context.parentObject) {
|
|
643
553
|
// TODO: Verify: If the xml:base has been set and the parentObject is the baseURI of the parent, then the subject needs to be the new base URI
|
|
644
554
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
645
|
-
|
|
646
555
|
if (!propertyAtt) {
|
|
647
556
|
skip = true;
|
|
648
557
|
}
|
|
649
558
|
}
|
|
650
559
|
}
|
|
651
|
-
|
|
652
560
|
if (typeofAtt) {
|
|
653
561
|
typedResource = newSubject;
|
|
654
562
|
}
|
|
655
|
-
}
|
|
563
|
+
}
|
|
564
|
+
// console.log(current.tagName+": newSubject="+newSubject+", currentObjectResource="+currentObjectResource+", typedResource="+typedResource+", skip="+skip)
|
|
656
565
|
// var rdfaData = null
|
|
657
|
-
|
|
658
|
-
|
|
659
566
|
if (newSubject) {
|
|
660
567
|
// this.newSubject(current,newSubject)
|
|
661
568
|
if (aboutAtt || resourceAtt || typedResource) {
|
|
662
569
|
var id = newSubject;
|
|
663
|
-
|
|
664
570
|
if (typeofAtt && !aboutAtt && !resourceAtt && currentObjectResource) {
|
|
665
571
|
id = currentObjectResource;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
|
|
572
|
+
}
|
|
573
|
+
// console.log("Setting data attribute for "+current.localName+" for subject "+id)
|
|
669
574
|
this.newSubjectOrigin(current, id);
|
|
670
575
|
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
576
|
+
}
|
|
577
|
+
// Sequence Step 7: generate type triple
|
|
674
578
|
if (typedResource) {
|
|
675
579
|
values = this.tokenize(typeofAtt.value);
|
|
676
|
-
|
|
677
580
|
for (var _i6 = 0; _i6 < values.length; _i6++) {
|
|
678
581
|
var object = this.parseTermOrCURIEOrAbsURI(values[_i6], vocabulary, context.terms, prefixes, base);
|
|
679
|
-
|
|
680
582
|
if (object) {
|
|
681
583
|
this.addTriple(current, typedResource, RDFaProcessor.typeURI, {
|
|
682
584
|
type: RDFaProcessor.objectURI,
|
|
@@ -684,27 +586,23 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
684
586
|
});
|
|
685
587
|
}
|
|
686
588
|
}
|
|
687
|
-
}
|
|
589
|
+
}
|
|
590
|
+
// Sequence Step 8: new list mappings if there is a new subject
|
|
688
591
|
// console.log("Step 8: newSubject="+newSubject+", context.parentObject="+context.parentObject)
|
|
689
|
-
|
|
690
|
-
|
|
691
592
|
if (newSubject && newSubject !== context.parentObject) {
|
|
692
593
|
// console.log("Generating new list mapping for "+newSubject)
|
|
693
594
|
listMapping = {};
|
|
694
595
|
listMappingDifferent = true;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
|
|
596
|
+
}
|
|
597
|
+
// Sequence Step 9: generate object triple
|
|
698
598
|
if (currentObjectResource) {
|
|
699
599
|
if (relAtt && inlistAtt) {
|
|
700
600
|
for (var _i7 = 0; _i7 < relAttPredicates.length; _i7++) {
|
|
701
601
|
var _list = listMapping[relAttPredicates[_i7]];
|
|
702
|
-
|
|
703
602
|
if (!_list) {
|
|
704
603
|
_list = [];
|
|
705
604
|
listMapping[relAttPredicates[_i7]] = _list;
|
|
706
605
|
}
|
|
707
|
-
|
|
708
606
|
_list.push({
|
|
709
607
|
type: RDFaProcessor.objectURI,
|
|
710
608
|
value: currentObjectResource
|
|
@@ -718,7 +616,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
718
616
|
});
|
|
719
617
|
}
|
|
720
618
|
}
|
|
721
|
-
|
|
722
619
|
if (revAtt) {
|
|
723
620
|
for (var _i9 = 0; _i9 < revAttPredicates.length; _i9++) {
|
|
724
621
|
this.addTriple(current, currentObjectResource, revAttPredicates[_i9], {
|
|
@@ -730,19 +627,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
730
627
|
} else {
|
|
731
628
|
// Sequence Step 10: incomplete triples
|
|
732
629
|
if (newSubject && !currentObjectResource && (relAtt || revAtt)) {
|
|
733
|
-
currentObjectResource = this.newBlankNode();
|
|
630
|
+
currentObjectResource = this.newBlankNode();
|
|
631
|
+
// alert(current.tagName+": generated blank node, newSubject="+newSubject+" currentObjectResource="+currentObjectResource)
|
|
734
632
|
}
|
|
735
633
|
|
|
736
634
|
if (relAtt && inlistAtt) {
|
|
737
635
|
for (var _i10 = 0; _i10 < relAttPredicates.length; _i10++) {
|
|
738
636
|
var _list2 = listMapping[relAttPredicates[_i10]];
|
|
739
|
-
|
|
740
637
|
if (!_list2) {
|
|
741
638
|
_list2 = [];
|
|
742
639
|
listMapping[predicate] = _list2;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
|
|
640
|
+
}
|
|
641
|
+
// console.log("Adding incomplete list for "+predicate)
|
|
746
642
|
incomplete.push({
|
|
747
643
|
predicate: relAttPredicates[_i10],
|
|
748
644
|
list: _list2
|
|
@@ -756,7 +652,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
756
652
|
});
|
|
757
653
|
}
|
|
758
654
|
}
|
|
759
|
-
|
|
760
655
|
if (revAtt) {
|
|
761
656
|
for (var _i12 = 0; _i12 < revAttPredicates.length; _i12++) {
|
|
762
657
|
incomplete.push({
|
|
@@ -765,16 +660,13 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
765
660
|
});
|
|
766
661
|
}
|
|
767
662
|
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
|
|
663
|
+
}
|
|
664
|
+
// Step 11: Current property values
|
|
771
665
|
if (propertyAtt) {
|
|
772
666
|
var datatype = null;
|
|
773
667
|
var content = null;
|
|
774
|
-
|
|
775
668
|
if (datatypeAtt) {
|
|
776
669
|
datatype = datatypeAtt.value === '' ? RDFaProcessor.PlainLiteralURI : this.parseTermOrCURIEOrAbsURI(datatypeAtt.value, vocabulary, context.terms, prefixes, base);
|
|
777
|
-
|
|
778
670
|
if (datetimeAtt && !contentAtt) {
|
|
779
671
|
content = datetimeAtt.value;
|
|
780
672
|
} else {
|
|
@@ -786,7 +678,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
786
678
|
} else if (datetimeAtt) {
|
|
787
679
|
content = datetimeAtt.value;
|
|
788
680
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
|
789
|
-
|
|
790
681
|
if (!datatype) {
|
|
791
682
|
datatype = RDFaProcessor.PlainLiteralURI;
|
|
792
683
|
}
|
|
@@ -794,49 +685,39 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
794
685
|
if (resourceAtt) {
|
|
795
686
|
content = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
796
687
|
}
|
|
797
|
-
|
|
798
688
|
if (!content && hrefAtt) {
|
|
799
689
|
content = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
800
690
|
} else if (!content && srcAtt) {
|
|
801
691
|
content = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
802
692
|
}
|
|
803
|
-
|
|
804
693
|
if (content) {
|
|
805
694
|
datatype = RDFaProcessor.objectURI;
|
|
806
695
|
}
|
|
807
696
|
}
|
|
808
|
-
|
|
809
697
|
if (!datatype) {
|
|
810
698
|
if (typeofAtt && !aboutAtt) {
|
|
811
699
|
datatype = RDFaProcessor.objectURI;
|
|
812
700
|
content = typedResource;
|
|
813
701
|
} else {
|
|
814
702
|
content = current.textContent;
|
|
815
|
-
|
|
816
703
|
if (this.inHTMLMode && current.localName === 'time') {
|
|
817
704
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
|
818
705
|
}
|
|
819
|
-
|
|
820
706
|
if (!datatype) {
|
|
821
707
|
datatype = RDFaProcessor.PlainLiteralURI;
|
|
822
708
|
}
|
|
823
709
|
}
|
|
824
710
|
}
|
|
825
|
-
|
|
826
711
|
values = this.tokenize(propertyAtt.value);
|
|
827
|
-
|
|
828
712
|
for (var _i13 = 0; _i13 < values.length; _i13++) {
|
|
829
713
|
var _predicate2 = this.parsePredicate(values[_i13], vocabulary, context.terms, prefixes, base);
|
|
830
|
-
|
|
831
714
|
if (_predicate2) {
|
|
832
715
|
if (inlistAtt) {
|
|
833
716
|
var _list3 = listMapping[_predicate2];
|
|
834
|
-
|
|
835
717
|
if (!_list3) {
|
|
836
718
|
_list3 = [];
|
|
837
719
|
listMapping[_predicate2] = _list3;
|
|
838
720
|
}
|
|
839
|
-
|
|
840
721
|
_list3.push(datatype === RDFaProcessor.XMLLiteralURI || datatype === RDFaProcessor.HTMLLiteralURI ? {
|
|
841
722
|
type: datatype,
|
|
842
723
|
value: current.childNodes
|
|
@@ -856,14 +737,14 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
856
737
|
type: datatype || RDFaProcessor.PlainLiteralURI,
|
|
857
738
|
value: content,
|
|
858
739
|
language: language
|
|
859
|
-
});
|
|
740
|
+
});
|
|
741
|
+
// console.log(newSubject+" "+predicate+"="+content)
|
|
860
742
|
}
|
|
861
743
|
}
|
|
862
744
|
}
|
|
863
745
|
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
746
|
+
}
|
|
747
|
+
// Sequence Step 12: complete incomplete triples with new subject
|
|
867
748
|
if (newSubject && !skip) {
|
|
868
749
|
for (var _i14 = 0; _i14 < context.incomplete.length; _i14++) {
|
|
869
750
|
if (context.incomplete[_i14].list) {
|
|
@@ -888,15 +769,13 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
888
769
|
}
|
|
889
770
|
}
|
|
890
771
|
}
|
|
891
|
-
|
|
892
772
|
var childContext = null;
|
|
893
773
|
var listSubject = newSubject;
|
|
894
|
-
|
|
895
774
|
if (skip) {
|
|
896
775
|
// TODO: should subject be null?
|
|
897
|
-
childContext = this.push(context, context.subject);
|
|
776
|
+
childContext = this.push(context, context.subject);
|
|
777
|
+
// TODO: should the entObject be passed along? If not, then intermediary children will keep properties from being associated with incomplete triples.
|
|
898
778
|
// TODO: Verify: if the current baseURI has changed and the parentObject is the parent's base URI, then the baseURI should change
|
|
899
|
-
|
|
900
779
|
childContext.parentObject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
901
780
|
childContext.incomplete = context.incomplete;
|
|
902
781
|
childContext.language = language;
|
|
@@ -907,19 +786,16 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
907
786
|
childContext.parentObject = currentObjectResource || newSubject || context.subject;
|
|
908
787
|
childContext.prefixes = prefixes;
|
|
909
788
|
childContext.incomplete = incomplete;
|
|
910
|
-
|
|
911
789
|
if (currentObjectResource) {
|
|
912
790
|
// console.log("Generating new list mapping for "+currentObjectResource)
|
|
913
791
|
listSubject = currentObjectResource;
|
|
914
792
|
listMapping = {};
|
|
915
793
|
listMappingDifferent = true;
|
|
916
794
|
}
|
|
917
|
-
|
|
918
795
|
childContext.listMapping = listMapping;
|
|
919
796
|
childContext.language = language;
|
|
920
797
|
childContext.vocabulary = vocabulary;
|
|
921
798
|
}
|
|
922
|
-
|
|
923
799
|
if (listMappingDifferent) {
|
|
924
800
|
// console.log("Pushing list parent "+current.localName)
|
|
925
801
|
queue.unshift({
|
|
@@ -929,7 +805,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
929
805
|
listMapping: listMapping
|
|
930
806
|
});
|
|
931
807
|
}
|
|
932
|
-
|
|
933
808
|
for (var child = current.lastChild; child; child = child.previousSibling) {
|
|
934
809
|
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
935
810
|
// console.log("Pushing child "+child.localName)
|
|
@@ -941,11 +816,9 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
941
816
|
}
|
|
942
817
|
}
|
|
943
818
|
}
|
|
944
|
-
|
|
945
819
|
if (this.inHTMLMode) {
|
|
946
820
|
this.copyProperties();
|
|
947
821
|
}
|
|
948
|
-
|
|
949
822
|
for (var _i15 = 0; _i15 < this.finishedHandlers.length; _i15++) {
|
|
950
823
|
this.finishedHandlers[_i15](node);
|
|
951
824
|
}
|
|
@@ -1011,8 +884,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1011
884
|
}, {
|
|
1012
885
|
key: "setInitialContext",
|
|
1013
886
|
value: function setInitialContext() {
|
|
1014
|
-
this.vocabulary = null;
|
|
1015
|
-
|
|
887
|
+
this.vocabulary = null;
|
|
888
|
+
// By default, the prefixes are terms are loaded to the RDFa 1.1. standard within the graph constructor
|
|
1016
889
|
this.langAttributes = [{
|
|
1017
890
|
namespaceURI: 'http://www.w3.org/XML/1998/namespace',
|
|
1018
891
|
localName: 'lang'
|
|
@@ -1030,8 +903,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1030
903
|
}, {
|
|
1031
904
|
namespaceURI: null,
|
|
1032
905
|
localName: 'lang'
|
|
1033
|
-
}];
|
|
1034
|
-
|
|
906
|
+
}];
|
|
907
|
+
// From http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
|
|
1035
908
|
this.target.graph.terms['alternate'] = 'http://www.w3.org/1999/xhtml/vocab#alternate';
|
|
1036
909
|
this.target.graph.terms['appendix'] = 'http://www.w3.org/1999/xhtml/vocab#appendix';
|
|
1037
910
|
this.target.graph.terms['bookmark'] = 'http://www.w3.org/1999/xhtml/vocab#bookmark';
|
|
@@ -1056,8 +929,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1056
929
|
this.target.graph.terms['start'] = 'http://www.w3.org/1999/xhtml/vocab#start';
|
|
1057
930
|
this.target.graph.terms['top'] = 'http://www.w3.org/1999/xhtml/vocab#top';
|
|
1058
931
|
this.target.graph.terms['up'] = 'http://www.w3.org/1999/xhtml/vocab#up';
|
|
1059
|
-
this.target.graph.terms['p3pv1'] = 'http://www.w3.org/1999/xhtml/vocab#p3pv1';
|
|
1060
|
-
|
|
932
|
+
this.target.graph.terms['p3pv1'] = 'http://www.w3.org/1999/xhtml/vocab#p3pv1';
|
|
933
|
+
// other
|
|
1061
934
|
this.target.graph.terms['related'] = 'http://www.w3.org/1999/xhtml/vocab#related';
|
|
1062
935
|
this.target.graph.terms['role'] = 'http://www.w3.org/1999/xhtml/vocab#role';
|
|
1063
936
|
this.target.graph.terms['transformation'] = 'http://www.w3.org/1999/xhtml/vocab#transformation';
|
|
@@ -1078,36 +951,27 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1078
951
|
key: "toRDFNodeObject",
|
|
1079
952
|
value: function toRDFNodeObject(x) {
|
|
1080
953
|
var _this = this;
|
|
1081
|
-
|
|
1082
954
|
if (typeof x === 'undefined') return undefined;
|
|
1083
|
-
|
|
1084
955
|
if (typeof x === 'string') {
|
|
1085
956
|
if (x.substring(0, 2) === '_:') {
|
|
1086
957
|
if (typeof this.blankNodes[x.substring(2)] === 'undefined') {
|
|
1087
958
|
this.blankNodes[x.substring(2)] = new BlankNode(x.substring(2));
|
|
1088
959
|
}
|
|
1089
|
-
|
|
1090
960
|
return this.blankNodes[x.substring(2)];
|
|
1091
961
|
}
|
|
1092
|
-
|
|
1093
962
|
return rdf.namedNode(x);
|
|
1094
963
|
}
|
|
1095
|
-
|
|
1096
964
|
switch (x.type) {
|
|
1097
965
|
case RDFaProcessor.objectURI:
|
|
1098
966
|
if (x.value.substring(0, 2) === '_:') {
|
|
1099
967
|
if (typeof this.blankNodes[x.value.substring(2)] === 'undefined') {
|
|
1100
968
|
this.blankNodes[x.value.substring(2)] = new BlankNode(x.value.substring(2));
|
|
1101
969
|
}
|
|
1102
|
-
|
|
1103
970
|
return this.blankNodes[x.value.substring(2)];
|
|
1104
971
|
}
|
|
1105
|
-
|
|
1106
972
|
return rdf.namedNode(x.value);
|
|
1107
|
-
|
|
1108
973
|
case RDFaProcessor.PlainLiteralURI:
|
|
1109
974
|
return new Literal(x.value, x.language || '');
|
|
1110
|
-
|
|
1111
975
|
case RDFaProcessor.XMLLiteralURI:
|
|
1112
976
|
case RDFaProcessor.HTMLLiteralURI:
|
|
1113
977
|
var string = '';
|
|
@@ -1115,7 +979,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1115
979
|
string += Util.domToString(x.value[i], _this.htmlOptions);
|
|
1116
980
|
});
|
|
1117
981
|
return new Literal(string, '', new NamedNode(x.type));
|
|
1118
|
-
|
|
1119
982
|
default:
|
|
1120
983
|
return new Literal(x.value, '', new NamedNode(x.type));
|
|
1121
984
|
}
|
|
@@ -1130,8 +993,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1130
993
|
value: function parseRDFaDOM(dom, kb, base) {
|
|
1131
994
|
var p = new RDFaProcessor(kb, {
|
|
1132
995
|
'base': base
|
|
1133
|
-
});
|
|
1134
|
-
|
|
996
|
+
});
|
|
997
|
+
// Cannot assign to read only property 'baseURI' of object '#<XMLDocument>':
|
|
1135
998
|
if (!dom.baseURI) {
|
|
1136
999
|
// Note this became a read-only attribute some time before 2018
|
|
1137
1000
|
dom.baseURI = base; // oinly set if not already set
|
|
@@ -1152,10 +1015,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1152
1015
|
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
|
1153
1016
|
}
|
|
1154
1017
|
}]);
|
|
1155
|
-
|
|
1156
1018
|
return RDFaProcessor;
|
|
1157
1019
|
}();
|
|
1158
|
-
|
|
1159
1020
|
export { RDFaProcessor as default };
|
|
1160
1021
|
RDFaProcessor.XMLLiteralURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral';
|
|
1161
1022
|
RDFaProcessor.HTMLLiteralURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML';
|
|
@@ -1165,6 +1026,7 @@ RDFaProcessor.typeURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
|
|
|
1165
1026
|
RDFaProcessor.nameChar = "[-A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF.0-9\xB7\u0300-\u036F\u203F-\u2040]";
|
|
1166
1027
|
RDFaProcessor.nameStartChar = "[A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3\u4E00-\u9FA5\u3007\u3021-\u3029_]";
|
|
1167
1028
|
RDFaProcessor.NCNAME = new RegExp('^' + RDFaProcessor.nameStartChar + RDFaProcessor.nameChar + '*$');
|
|
1029
|
+
|
|
1168
1030
|
/*
|
|
1169
1031
|
RDFaProcessor.prototype.resolveAndNormalize = function(base,href) {
|
|
1170
1032
|
var u = base.resolve(href)
|