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/lib/rdfaparser.js
CHANGED
|
@@ -1,43 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.parseRDFaDOM = exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _blankNode = _interopRequireDefault(require("./blank-node"));
|
|
17
|
-
|
|
18
12
|
var _literal = _interopRequireDefault(require("./literal"));
|
|
19
|
-
|
|
20
13
|
var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
21
|
-
|
|
22
14
|
var Uri = _interopRequireWildcard(require("./uri"));
|
|
23
|
-
|
|
24
15
|
var Util = _interopRequireWildcard(require("./utils-js"));
|
|
25
|
-
|
|
26
16
|
var _canonicalDataFactory = _interopRequireDefault(require("./factories/canonical-data-factory"));
|
|
27
|
-
|
|
28
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
19
|
// RDFa Parser for rdflib.js
|
|
20
|
+
|
|
33
21
|
// Originally by: Alex Milowski
|
|
34
22
|
// From https://github.com/alexmilowski/green-turtle
|
|
35
23
|
// Converted: timbl 2015-08-25 not yet working
|
|
36
24
|
// Added wrapper: csarven 2016-05-09 working
|
|
25
|
+
|
|
37
26
|
// RDFaProcessor.prototype = new Object() // Was URIResolver
|
|
27
|
+
|
|
38
28
|
// RDFaProcessor.prototype.constructor=RDFaProcessor
|
|
29
|
+
|
|
39
30
|
// options.base = base URI not really an option, shopuld always be set.
|
|
40
31
|
//
|
|
32
|
+
|
|
41
33
|
if (typeof Node === 'undefined') {
|
|
42
34
|
// @@@@@@ Global. Interface to xmldom.
|
|
43
35
|
var Node = {
|
|
@@ -55,7 +47,6 @@ if (typeof Node === 'undefined') {
|
|
|
55
47
|
NOTATION_NODE: 12
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
|
-
|
|
59
50
|
var RDFaProcessor = /*#__PURE__*/function () {
|
|
60
51
|
function RDFaProcessor(kb, options) {
|
|
61
52
|
(0, _classCallCheck2.default)(this, RDFaProcessor);
|
|
@@ -67,10 +58,10 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
67
58
|
prefixes: {},
|
|
68
59
|
terms: {}
|
|
69
60
|
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.blankNodes = [];
|
|
73
|
-
|
|
61
|
+
};
|
|
62
|
+
// XXX: Added to track bnodes
|
|
63
|
+
this.blankNodes = [];
|
|
64
|
+
// XXX: Added for normalisation
|
|
74
65
|
this.htmlOptions = {
|
|
75
66
|
'selfClosing': 'br img input area base basefont col colgroup source wbr isindex link meta param hr'
|
|
76
67
|
};
|
|
@@ -87,45 +78,38 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
87
78
|
this.finishedHandlers = [];
|
|
88
79
|
this.init();
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
(0, _createClass2.default)(RDFaProcessor, [{
|
|
92
82
|
key: "addTriple",
|
|
93
83
|
value: function addTriple(origin, subject, predicate, object) {
|
|
94
84
|
var su, ob, pr, or;
|
|
95
|
-
|
|
96
85
|
if (typeof subject === 'undefined') {
|
|
97
86
|
su = _canonicalDataFactory.default.namedNode(this.options.base);
|
|
98
87
|
} else {
|
|
99
88
|
su = this.toRDFNodeObject(subject);
|
|
100
89
|
}
|
|
101
|
-
|
|
102
90
|
pr = this.toRDFNodeObject(predicate);
|
|
103
91
|
ob = this.toRDFNodeObject(object);
|
|
104
|
-
or = _canonicalDataFactory.default.namedNode(this.options.base);
|
|
105
|
-
|
|
92
|
+
or = _canonicalDataFactory.default.namedNode(this.options.base);
|
|
93
|
+
// console.log('Adding { ' + su + ' ' + pr + ' ' + ob + ' ' + or + ' }')
|
|
106
94
|
this.kb.add(su, pr, ob, or);
|
|
107
95
|
}
|
|
108
96
|
}, {
|
|
109
97
|
key: "ancestorPath",
|
|
110
98
|
value: function ancestorPath(node) {
|
|
111
99
|
var path = '';
|
|
112
|
-
|
|
113
100
|
while (node && node.nodeType !== Node.DOCUMENT_NODE) {
|
|
114
101
|
path = '/' + node.localName + path;
|
|
115
102
|
node = node.parentNode;
|
|
116
103
|
}
|
|
117
|
-
|
|
118
104
|
return path;
|
|
119
105
|
}
|
|
120
106
|
}, {
|
|
121
107
|
key: "copyMappings",
|
|
122
108
|
value: function copyMappings(mappings) {
|
|
123
109
|
var newMappings = {};
|
|
124
|
-
|
|
125
110
|
for (var k in mappings) {
|
|
126
111
|
newMappings[k] = mappings[k];
|
|
127
112
|
}
|
|
128
|
-
|
|
129
113
|
return newMappings;
|
|
130
114
|
}
|
|
131
115
|
}, {
|
|
@@ -137,13 +121,11 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
137
121
|
for (var i = 0; i < RDFaProcessor.dateTimeTypes.length; i++) {
|
|
138
122
|
// console.log("Checking "+value+" against "+RDFaProcessor.dateTimeTypes[i].type)
|
|
139
123
|
var matched = RDFaProcessor.dateTimeTypes[i].pattern.exec(value);
|
|
140
|
-
|
|
141
124
|
if (matched && matched[0].length === value.length) {
|
|
142
125
|
// console.log("Matched!")
|
|
143
126
|
return RDFaProcessor.dateTimeTypes[i].type;
|
|
144
127
|
}
|
|
145
128
|
}
|
|
146
|
-
|
|
147
129
|
return null;
|
|
148
130
|
}
|
|
149
131
|
}, {
|
|
@@ -163,10 +145,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
163
145
|
value: function parseCURIE(value, prefixes, base) {
|
|
164
146
|
var colon = value.indexOf(':');
|
|
165
147
|
var uri;
|
|
166
|
-
|
|
167
148
|
if (colon >= 0) {
|
|
168
149
|
var prefix = value.substring(0, colon);
|
|
169
|
-
|
|
170
150
|
if (prefix === '') {
|
|
171
151
|
// default prefix
|
|
172
152
|
uri = prefixes[''];
|
|
@@ -176,24 +156,20 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
176
156
|
return '_:' + value.substring(colon + 1);
|
|
177
157
|
} else if (RDFaProcessor.NCNAME.test(prefix)) {
|
|
178
158
|
uri = prefixes[prefix];
|
|
179
|
-
|
|
180
159
|
if (uri) {
|
|
181
160
|
return uri + value.substring(colon + 1);
|
|
182
161
|
}
|
|
183
162
|
}
|
|
184
163
|
}
|
|
185
|
-
|
|
186
164
|
return null;
|
|
187
165
|
}
|
|
188
166
|
}, {
|
|
189
167
|
key: "parseCURIEOrURI",
|
|
190
168
|
value: function parseCURIEOrURI(value, prefixes, base) {
|
|
191
169
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
192
|
-
|
|
193
170
|
if (curie) {
|
|
194
171
|
return curie;
|
|
195
172
|
}
|
|
196
|
-
|
|
197
173
|
return this.resolveAndNormalize(base, value);
|
|
198
174
|
}
|
|
199
175
|
}, {
|
|
@@ -202,21 +178,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
202
178
|
if (value === '') {
|
|
203
179
|
return null;
|
|
204
180
|
}
|
|
205
|
-
|
|
206
181
|
var predicate = this.parseTermOrCURIEOrAbsURI(value, defaultVocabulary, ignoreTerms ? null : terms, prefixes, base);
|
|
207
|
-
|
|
208
182
|
if (predicate && predicate.indexOf('_:') === 0) {
|
|
209
183
|
return null;
|
|
210
184
|
}
|
|
211
|
-
|
|
212
185
|
return predicate;
|
|
213
186
|
}
|
|
214
187
|
}, {
|
|
215
188
|
key: "parsePrefixMappings",
|
|
216
189
|
value: function parsePrefixMappings(str, target) {
|
|
217
190
|
var values = this.tokenize(str);
|
|
218
|
-
var prefix = null;
|
|
219
|
-
|
|
191
|
+
var prefix = null;
|
|
192
|
+
// var uri = null
|
|
220
193
|
for (var i = 0; i < values.length; i++) {
|
|
221
194
|
if (values[i][values[i].length - 1] === ':') {
|
|
222
195
|
prefix = values[i].substring(0, values[i].length - 1);
|
|
@@ -230,20 +203,16 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
230
203
|
key: "parseSafeCURIEOrCURIEOrURI",
|
|
231
204
|
value: function parseSafeCURIEOrCURIEOrURI(value, prefixes, base) {
|
|
232
205
|
value = this.trim(value);
|
|
233
|
-
|
|
234
206
|
if (value.charAt(0) === '[' && value.charAt(value.length - 1) === ']') {
|
|
235
207
|
value = value.substring(1, value.length - 1);
|
|
236
208
|
value = value.trim(value);
|
|
237
|
-
|
|
238
209
|
if (value.length === 0) {
|
|
239
210
|
return null;
|
|
240
211
|
}
|
|
241
|
-
|
|
242
212
|
if (value === '_:') {
|
|
243
213
|
// the one node
|
|
244
214
|
return this.theOne;
|
|
245
215
|
}
|
|
246
|
-
|
|
247
216
|
return this.parseCURIE(value, prefixes, base);
|
|
248
217
|
} else {
|
|
249
218
|
return this.parseCURIEOrURI(value, prefixes, base);
|
|
@@ -255,32 +224,25 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
255
224
|
// alert("Parsing "+value+" with default vocab "+defaultVocabulary)
|
|
256
225
|
value = this.trim(value);
|
|
257
226
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
258
|
-
|
|
259
227
|
if (curie) {
|
|
260
228
|
return curie;
|
|
261
229
|
} else if (terms) {
|
|
262
230
|
if (defaultVocabulary && !this.absURIRE.exec(value)) {
|
|
263
231
|
return defaultVocabulary + value;
|
|
264
232
|
}
|
|
265
|
-
|
|
266
233
|
var term = terms[value];
|
|
267
|
-
|
|
268
234
|
if (term) {
|
|
269
235
|
return term;
|
|
270
236
|
}
|
|
271
|
-
|
|
272
237
|
var lcvalue = value.toLowerCase();
|
|
273
238
|
term = terms[lcvalue];
|
|
274
|
-
|
|
275
239
|
if (term) {
|
|
276
240
|
return term;
|
|
277
241
|
}
|
|
278
242
|
}
|
|
279
|
-
|
|
280
243
|
if (this.absURIRE.exec(value)) {
|
|
281
244
|
return this.resolveAndNormalize(base, value);
|
|
282
245
|
}
|
|
283
|
-
|
|
284
246
|
return null;
|
|
285
247
|
}
|
|
286
248
|
}, {
|
|
@@ -289,28 +251,22 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
289
251
|
// alert("Parsing "+value+" with default vocab "+defaultVocabulary)
|
|
290
252
|
value = this.trim(value);
|
|
291
253
|
var curie = this.parseCURIE(value, prefixes, base);
|
|
292
|
-
|
|
293
254
|
if (curie) {
|
|
294
255
|
return curie;
|
|
295
256
|
} else {
|
|
296
257
|
var term = terms[value];
|
|
297
|
-
|
|
298
258
|
if (term) {
|
|
299
259
|
return term;
|
|
300
260
|
}
|
|
301
|
-
|
|
302
261
|
var lcvalue = value.toLowerCase();
|
|
303
262
|
term = terms[lcvalue];
|
|
304
|
-
|
|
305
263
|
if (term) {
|
|
306
264
|
return term;
|
|
307
265
|
}
|
|
308
|
-
|
|
309
266
|
if (defaultVocabulary && !this.absURIRE.exec(value)) {
|
|
310
267
|
return defaultVocabulary + value;
|
|
311
268
|
}
|
|
312
269
|
}
|
|
313
|
-
|
|
314
270
|
return this.resolveAndNormalize(base, value);
|
|
315
271
|
}
|
|
316
272
|
}, {
|
|
@@ -327,7 +283,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
327
283
|
} */
|
|
328
284
|
options = options || {};
|
|
329
285
|
var base;
|
|
330
|
-
|
|
331
286
|
if (node.nodeType === Node.DOCUMENT_NODE) {
|
|
332
287
|
if (node.baseURI && !options.baseURI) {
|
|
333
288
|
options.baseURI = node.baseURI; // be defensive as DOM implementations vary
|
|
@@ -335,56 +290,44 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
335
290
|
|
|
336
291
|
base = node.baseURI;
|
|
337
292
|
node = node.documentElement;
|
|
338
|
-
|
|
339
293
|
if (!node.baseURI) {
|
|
340
294
|
node.baseURI = base;
|
|
341
295
|
}
|
|
342
|
-
|
|
343
296
|
this.setContext(node);
|
|
344
297
|
} else if (node.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
345
298
|
this.setContext(node);
|
|
346
299
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
300
|
+
var queue = [];
|
|
301
|
+
// Fix for Firefox that includes the hash in the base URI
|
|
350
302
|
var removeHash = function removeHash(baseURI) {
|
|
351
303
|
// Fix for undefined baseURI property
|
|
352
304
|
if (!baseURI && options && options.baseURI) {
|
|
353
305
|
return options.baseURI;
|
|
354
306
|
}
|
|
355
|
-
|
|
356
307
|
var hash = baseURI.indexOf('#');
|
|
357
|
-
|
|
358
308
|
if (hash >= 0) {
|
|
359
309
|
baseURI = baseURI.substring(0, hash);
|
|
360
310
|
}
|
|
361
|
-
|
|
362
311
|
if (options && options.baseURIMap) {
|
|
363
312
|
baseURI = options.baseURIMap(baseURI);
|
|
364
313
|
}
|
|
365
|
-
|
|
366
314
|
return baseURI;
|
|
367
315
|
};
|
|
368
|
-
|
|
369
316
|
queue.push({
|
|
370
317
|
current: node,
|
|
371
318
|
context: this.push(null, removeHash(node.baseURI))
|
|
372
319
|
});
|
|
373
|
-
|
|
374
320
|
while (queue.length > 0) {
|
|
375
321
|
var item = queue.shift();
|
|
376
|
-
|
|
377
322
|
if (item.parent) {
|
|
378
323
|
// Sequence Step 14: list triple generation
|
|
379
324
|
if (item.context.parent && item.context.parent.listMapping === item.listMapping) {
|
|
380
325
|
// Skip a child context with exactly the same mapping
|
|
381
326
|
continue;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
327
|
+
}
|
|
328
|
+
// console.log("Generating lists for "+item.subject+", tag "+item.parent.localName)
|
|
385
329
|
for (var _predicate in item.listMapping) {
|
|
386
330
|
var list = item.listMapping[_predicate];
|
|
387
|
-
|
|
388
331
|
if (list.length === 0) {
|
|
389
332
|
this.addTriple(item.parent, item.subject, _predicate, {
|
|
390
333
|
type: RDFaProcessor.objectURI,
|
|
@@ -392,11 +335,10 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
392
335
|
});
|
|
393
336
|
continue;
|
|
394
337
|
}
|
|
395
|
-
|
|
396
338
|
var bnodes = [];
|
|
397
|
-
|
|
398
339
|
for (var _i = 0; _i < list.length; _i++) {
|
|
399
|
-
bnodes.push(this.newBlankNode());
|
|
340
|
+
bnodes.push(this.newBlankNode());
|
|
341
|
+
// this.newSubject(item.parent,bnodes[i])
|
|
400
342
|
}
|
|
401
343
|
|
|
402
344
|
for (var _i2 = 0; _i2 < bnodes.length; _i2++) {
|
|
@@ -406,20 +348,17 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
406
348
|
value: _i2 + 1 < bnodes.length ? bnodes[_i2 + 1] : 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'
|
|
407
349
|
});
|
|
408
350
|
}
|
|
409
|
-
|
|
410
351
|
this.addTriple(item.parent, item.subject, _predicate, {
|
|
411
352
|
type: RDFaProcessor.objectURI,
|
|
412
353
|
value: bnodes[0]
|
|
413
354
|
});
|
|
414
355
|
}
|
|
415
|
-
|
|
416
356
|
continue;
|
|
417
357
|
}
|
|
418
|
-
|
|
419
358
|
var current = item.current;
|
|
420
|
-
var context = item.context;
|
|
359
|
+
var context = item.context;
|
|
360
|
+
// console.log("Tag: "+current.localName+", listMapping="+JSON.stringify(context.listMapping))
|
|
421
361
|
// Sequence Step 1
|
|
422
|
-
|
|
423
362
|
var skip = false;
|
|
424
363
|
var newSubject = null;
|
|
425
364
|
var currentObjectResource = null;
|
|
@@ -430,20 +369,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
430
369
|
var listMapping = context.listMapping;
|
|
431
370
|
var listMappingDifferent = !context.parent;
|
|
432
371
|
var language = context.language;
|
|
433
|
-
var vocabulary = context.vocabulary;
|
|
434
|
-
|
|
372
|
+
var vocabulary = context.vocabulary;
|
|
373
|
+
// TODO: the "base" element may be used for HTML+RDFa 1.1
|
|
435
374
|
base = this.parseURI(removeHash(current.baseURI));
|
|
436
|
-
current.item = null;
|
|
437
|
-
|
|
375
|
+
current.item = null;
|
|
376
|
+
// Sequence Step 2: set the default vocabulary
|
|
438
377
|
var vocabAtt = current.getAttributeNode('vocab');
|
|
439
|
-
|
|
440
378
|
if (vocabAtt) {
|
|
441
379
|
var value = this.trim(vocabAtt.value);
|
|
442
|
-
|
|
443
380
|
if (value.length > 0) {
|
|
444
381
|
vocabulary = value;
|
|
445
|
-
var baseSubject = base.spec;
|
|
446
|
-
|
|
382
|
+
var baseSubject = base.spec;
|
|
383
|
+
// this.newSubject(current,baseSubject)
|
|
447
384
|
this.addTriple(current, baseSubject, 'http://www.w3.org/ns/rdfa#usesVocabulary', {
|
|
448
385
|
type: RDFaProcessor.objectURI,
|
|
449
386
|
value: vocabulary
|
|
@@ -451,55 +388,45 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
451
388
|
} else {
|
|
452
389
|
vocabulary = this.vocabulary;
|
|
453
390
|
}
|
|
454
|
-
}
|
|
391
|
+
}
|
|
392
|
+
// Sequence Step 3: IRI mappings
|
|
455
393
|
// handle xmlns attributes
|
|
456
|
-
|
|
457
|
-
|
|
458
394
|
for (var i = 0; i < current.attributes.length; i++) {
|
|
459
|
-
var att = current.attributes[i];
|
|
460
|
-
|
|
395
|
+
var att = current.attributes[i];
|
|
396
|
+
// if (att.namespaceURI=="http://www.w3.org/2000/xmlns/") {
|
|
461
397
|
if (att.nodeName.charAt(0) === 'x' && att.nodeName.indexOf('xmlns:') === 0) {
|
|
462
398
|
if (!prefixesCopied) {
|
|
463
399
|
prefixes = this.copyMappings(prefixes);
|
|
464
400
|
prefixesCopied = true;
|
|
465
401
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
402
|
+
var prefix = att.nodeName.substring(6);
|
|
403
|
+
// TODO: resolve relative?
|
|
469
404
|
var ref = RDFaProcessor.trim(att.value);
|
|
470
405
|
prefixes[prefix] = this.options.base ? Uri.join(ref, this.options.base) : ref;
|
|
471
406
|
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
407
|
+
}
|
|
408
|
+
// Handle prefix mappings (@prefix)
|
|
475
409
|
var prefixAtt = current.getAttributeNode('prefix');
|
|
476
|
-
|
|
477
410
|
if (prefixAtt) {
|
|
478
411
|
if (!prefixesCopied) {
|
|
479
412
|
prefixes = this.copyMappings(prefixes);
|
|
480
413
|
prefixesCopied = true;
|
|
481
414
|
}
|
|
482
|
-
|
|
483
415
|
this.parsePrefixMappings(prefixAtt.value, prefixes);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
416
|
+
}
|
|
417
|
+
// Sequence Step 4: language
|
|
487
418
|
var xmlLangAtt = null;
|
|
488
|
-
|
|
489
419
|
for (var _i3 = 0; !xmlLangAtt && _i3 < this.langAttributes.length; _i3++) {
|
|
490
420
|
xmlLangAtt = current.getAttributeNodeNS(this.langAttributes[_i3].namespaceURI, this.langAttributes[_i3].localName);
|
|
491
421
|
}
|
|
492
|
-
|
|
493
422
|
if (xmlLangAtt) {
|
|
494
423
|
var _value = RDFaProcessor.trim(xmlLangAtt.value);
|
|
495
|
-
|
|
496
424
|
if (_value.length > 0) {
|
|
497
425
|
language = _value;
|
|
498
426
|
} else {
|
|
499
427
|
language = null;
|
|
500
428
|
}
|
|
501
429
|
}
|
|
502
|
-
|
|
503
430
|
var relAtt = current.getAttributeNode('rel');
|
|
504
431
|
var revAtt = current.getAttributeNode('rev');
|
|
505
432
|
var typeofAtt = current.getAttributeNode('typeof');
|
|
@@ -514,54 +441,42 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
514
441
|
var inlistAtt = current.getAttributeNode('inlist');
|
|
515
442
|
var relAttPredicates = [];
|
|
516
443
|
var predicate, values;
|
|
517
|
-
|
|
518
444
|
if (relAtt) {
|
|
519
445
|
values = this.tokenize(relAtt.value);
|
|
520
|
-
|
|
521
446
|
for (var _i4 = 0; _i4 < values.length; _i4++) {
|
|
522
447
|
predicate = this.parsePredicate(values[_i4], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt !== null);
|
|
523
|
-
|
|
524
448
|
if (predicate) {
|
|
525
449
|
relAttPredicates.push(predicate);
|
|
526
450
|
}
|
|
527
451
|
}
|
|
528
452
|
}
|
|
529
|
-
|
|
530
453
|
var revAttPredicates = [];
|
|
531
|
-
|
|
532
454
|
if (revAtt) {
|
|
533
455
|
values = this.tokenize(revAtt.value);
|
|
534
|
-
|
|
535
456
|
for (var _i5 = 0; _i5 < values.length; _i5++) {
|
|
536
457
|
predicate = this.parsePredicate(values[_i5], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt);
|
|
537
|
-
|
|
538
458
|
if (predicate) {
|
|
539
459
|
revAttPredicates.push(predicate);
|
|
540
460
|
}
|
|
541
461
|
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
462
|
+
}
|
|
463
|
+
// Section 3.1, bullet 7
|
|
545
464
|
if (this.inHTMLMode && (relAtt || revAtt) && propertyAtt) {
|
|
546
465
|
if (relAttPredicates.length === 0) {
|
|
547
466
|
relAtt = null;
|
|
548
467
|
}
|
|
549
|
-
|
|
550
468
|
if (revAttPredicates.length === 0) {
|
|
551
469
|
revAtt = null;
|
|
552
470
|
}
|
|
553
471
|
}
|
|
554
|
-
|
|
555
472
|
if (relAtt || revAtt) {
|
|
556
473
|
// Sequence Step 6: establish new subject and value
|
|
557
474
|
if (aboutAtt) {
|
|
558
475
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
559
476
|
}
|
|
560
|
-
|
|
561
477
|
if (typeofAtt) {
|
|
562
478
|
typedResource = newSubject;
|
|
563
479
|
}
|
|
564
|
-
|
|
565
480
|
if (!newSubject) {
|
|
566
481
|
if (current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
567
482
|
newSubject = removeHash(current.baseURI);
|
|
@@ -570,11 +485,9 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
570
485
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
571
486
|
}
|
|
572
487
|
}
|
|
573
|
-
|
|
574
488
|
if (resourceAtt) {
|
|
575
489
|
currentObjectResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
576
490
|
}
|
|
577
|
-
|
|
578
491
|
if (!currentObjectResource) {
|
|
579
492
|
if (hrefAtt) {
|
|
580
493
|
currentObjectResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
@@ -584,7 +497,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
584
497
|
currentObjectResource = this.newBlankNode();
|
|
585
498
|
}
|
|
586
499
|
}
|
|
587
|
-
|
|
588
500
|
if (typeofAtt && !aboutAtt && this.inXHTMLMode && (current.localName === 'head' || current.localName === 'body')) {
|
|
589
501
|
typedResource = newSubject;
|
|
590
502
|
} else if (typeofAtt && !aboutAtt) {
|
|
@@ -594,15 +506,12 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
594
506
|
// Sequence Step 5.1: establish a new subject
|
|
595
507
|
if (aboutAtt) {
|
|
596
508
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
597
|
-
|
|
598
509
|
if (typeofAtt) {
|
|
599
510
|
typedResource = newSubject;
|
|
600
511
|
}
|
|
601
512
|
}
|
|
602
|
-
|
|
603
513
|
if (!newSubject && current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
604
514
|
newSubject = removeHash(current.baseURI);
|
|
605
|
-
|
|
606
515
|
if (typeofAtt) {
|
|
607
516
|
typedResource = newSubject;
|
|
608
517
|
}
|
|
@@ -610,49 +519,39 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
610
519
|
// 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
|
|
611
520
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
612
521
|
}
|
|
613
|
-
|
|
614
522
|
if (typeofAtt && !typedResource) {
|
|
615
523
|
if (resourceAtt) {
|
|
616
524
|
typedResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
617
525
|
}
|
|
618
|
-
|
|
619
526
|
if (!typedResource && hrefAtt) {
|
|
620
527
|
typedResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
621
528
|
}
|
|
622
|
-
|
|
623
529
|
if (!typedResource && srcAtt) {
|
|
624
530
|
typedResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
625
531
|
}
|
|
626
|
-
|
|
627
532
|
if (!typedResource && (this.inXHTMLMode || this.inHTMLMode) && (current.localName === 'head' || current.localName === 'body')) {
|
|
628
533
|
typedResource = newSubject;
|
|
629
534
|
}
|
|
630
|
-
|
|
631
535
|
if (!typedResource) {
|
|
632
536
|
typedResource = this.newBlankNode();
|
|
633
537
|
}
|
|
634
|
-
|
|
635
538
|
currentObjectResource = typedResource;
|
|
636
|
-
}
|
|
637
|
-
|
|
539
|
+
}
|
|
540
|
+
// console.log(current.localName+", newSubject="+newSubject+", typedResource="+typedResource+", currentObjectResource="+currentObjectResource)
|
|
638
541
|
} else {
|
|
639
542
|
// Sequence Step 5.2: establish a new subject
|
|
640
543
|
if (aboutAtt) {
|
|
641
544
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
|
|
642
545
|
}
|
|
643
|
-
|
|
644
546
|
if (!newSubject && resourceAtt) {
|
|
645
547
|
newSubject = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
646
548
|
}
|
|
647
|
-
|
|
648
549
|
if (!newSubject && hrefAtt) {
|
|
649
550
|
newSubject = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
650
551
|
}
|
|
651
|
-
|
|
652
552
|
if (!newSubject && srcAtt) {
|
|
653
553
|
newSubject = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
654
554
|
}
|
|
655
|
-
|
|
656
555
|
if (!newSubject) {
|
|
657
556
|
if (current.parentNode.nodeType === Node.DOCUMENT_NODE) {
|
|
658
557
|
newSubject = removeHash(current.baseURI);
|
|
@@ -663,41 +562,33 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
663
562
|
} else if (context.parentObject) {
|
|
664
563
|
// 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
|
|
665
564
|
newSubject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
666
|
-
|
|
667
565
|
if (!propertyAtt) {
|
|
668
566
|
skip = true;
|
|
669
567
|
}
|
|
670
568
|
}
|
|
671
569
|
}
|
|
672
|
-
|
|
673
570
|
if (typeofAtt) {
|
|
674
571
|
typedResource = newSubject;
|
|
675
572
|
}
|
|
676
|
-
}
|
|
573
|
+
}
|
|
574
|
+
// console.log(current.tagName+": newSubject="+newSubject+", currentObjectResource="+currentObjectResource+", typedResource="+typedResource+", skip="+skip)
|
|
677
575
|
// var rdfaData = null
|
|
678
|
-
|
|
679
|
-
|
|
680
576
|
if (newSubject) {
|
|
681
577
|
// this.newSubject(current,newSubject)
|
|
682
578
|
if (aboutAtt || resourceAtt || typedResource) {
|
|
683
579
|
var id = newSubject;
|
|
684
|
-
|
|
685
580
|
if (typeofAtt && !aboutAtt && !resourceAtt && currentObjectResource) {
|
|
686
581
|
id = currentObjectResource;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
582
|
+
}
|
|
583
|
+
// console.log("Setting data attribute for "+current.localName+" for subject "+id)
|
|
690
584
|
this.newSubjectOrigin(current, id);
|
|
691
585
|
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
586
|
+
}
|
|
587
|
+
// Sequence Step 7: generate type triple
|
|
695
588
|
if (typedResource) {
|
|
696
589
|
values = this.tokenize(typeofAtt.value);
|
|
697
|
-
|
|
698
590
|
for (var _i6 = 0; _i6 < values.length; _i6++) {
|
|
699
591
|
var object = this.parseTermOrCURIEOrAbsURI(values[_i6], vocabulary, context.terms, prefixes, base);
|
|
700
|
-
|
|
701
592
|
if (object) {
|
|
702
593
|
this.addTriple(current, typedResource, RDFaProcessor.typeURI, {
|
|
703
594
|
type: RDFaProcessor.objectURI,
|
|
@@ -705,27 +596,23 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
705
596
|
});
|
|
706
597
|
}
|
|
707
598
|
}
|
|
708
|
-
}
|
|
599
|
+
}
|
|
600
|
+
// Sequence Step 8: new list mappings if there is a new subject
|
|
709
601
|
// console.log("Step 8: newSubject="+newSubject+", context.parentObject="+context.parentObject)
|
|
710
|
-
|
|
711
|
-
|
|
712
602
|
if (newSubject && newSubject !== context.parentObject) {
|
|
713
603
|
// console.log("Generating new list mapping for "+newSubject)
|
|
714
604
|
listMapping = {};
|
|
715
605
|
listMappingDifferent = true;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
|
|
606
|
+
}
|
|
607
|
+
// Sequence Step 9: generate object triple
|
|
719
608
|
if (currentObjectResource) {
|
|
720
609
|
if (relAtt && inlistAtt) {
|
|
721
610
|
for (var _i7 = 0; _i7 < relAttPredicates.length; _i7++) {
|
|
722
611
|
var _list = listMapping[relAttPredicates[_i7]];
|
|
723
|
-
|
|
724
612
|
if (!_list) {
|
|
725
613
|
_list = [];
|
|
726
614
|
listMapping[relAttPredicates[_i7]] = _list;
|
|
727
615
|
}
|
|
728
|
-
|
|
729
616
|
_list.push({
|
|
730
617
|
type: RDFaProcessor.objectURI,
|
|
731
618
|
value: currentObjectResource
|
|
@@ -739,7 +626,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
739
626
|
});
|
|
740
627
|
}
|
|
741
628
|
}
|
|
742
|
-
|
|
743
629
|
if (revAtt) {
|
|
744
630
|
for (var _i9 = 0; _i9 < revAttPredicates.length; _i9++) {
|
|
745
631
|
this.addTriple(current, currentObjectResource, revAttPredicates[_i9], {
|
|
@@ -751,19 +637,18 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
751
637
|
} else {
|
|
752
638
|
// Sequence Step 10: incomplete triples
|
|
753
639
|
if (newSubject && !currentObjectResource && (relAtt || revAtt)) {
|
|
754
|
-
currentObjectResource = this.newBlankNode();
|
|
640
|
+
currentObjectResource = this.newBlankNode();
|
|
641
|
+
// alert(current.tagName+": generated blank node, newSubject="+newSubject+" currentObjectResource="+currentObjectResource)
|
|
755
642
|
}
|
|
756
643
|
|
|
757
644
|
if (relAtt && inlistAtt) {
|
|
758
645
|
for (var _i10 = 0; _i10 < relAttPredicates.length; _i10++) {
|
|
759
646
|
var _list2 = listMapping[relAttPredicates[_i10]];
|
|
760
|
-
|
|
761
647
|
if (!_list2) {
|
|
762
648
|
_list2 = [];
|
|
763
649
|
listMapping[predicate] = _list2;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
|
|
650
|
+
}
|
|
651
|
+
// console.log("Adding incomplete list for "+predicate)
|
|
767
652
|
incomplete.push({
|
|
768
653
|
predicate: relAttPredicates[_i10],
|
|
769
654
|
list: _list2
|
|
@@ -777,7 +662,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
777
662
|
});
|
|
778
663
|
}
|
|
779
664
|
}
|
|
780
|
-
|
|
781
665
|
if (revAtt) {
|
|
782
666
|
for (var _i12 = 0; _i12 < revAttPredicates.length; _i12++) {
|
|
783
667
|
incomplete.push({
|
|
@@ -786,16 +670,13 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
786
670
|
});
|
|
787
671
|
}
|
|
788
672
|
}
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
|
|
673
|
+
}
|
|
674
|
+
// Step 11: Current property values
|
|
792
675
|
if (propertyAtt) {
|
|
793
676
|
var datatype = null;
|
|
794
677
|
var content = null;
|
|
795
|
-
|
|
796
678
|
if (datatypeAtt) {
|
|
797
679
|
datatype = datatypeAtt.value === '' ? RDFaProcessor.PlainLiteralURI : this.parseTermOrCURIEOrAbsURI(datatypeAtt.value, vocabulary, context.terms, prefixes, base);
|
|
798
|
-
|
|
799
680
|
if (datetimeAtt && !contentAtt) {
|
|
800
681
|
content = datetimeAtt.value;
|
|
801
682
|
} else {
|
|
@@ -807,7 +688,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
807
688
|
} else if (datetimeAtt) {
|
|
808
689
|
content = datetimeAtt.value;
|
|
809
690
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
|
810
|
-
|
|
811
691
|
if (!datatype) {
|
|
812
692
|
datatype = RDFaProcessor.PlainLiteralURI;
|
|
813
693
|
}
|
|
@@ -815,49 +695,39 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
815
695
|
if (resourceAtt) {
|
|
816
696
|
content = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
|
|
817
697
|
}
|
|
818
|
-
|
|
819
698
|
if (!content && hrefAtt) {
|
|
820
699
|
content = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
|
|
821
700
|
} else if (!content && srcAtt) {
|
|
822
701
|
content = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
|
|
823
702
|
}
|
|
824
|
-
|
|
825
703
|
if (content) {
|
|
826
704
|
datatype = RDFaProcessor.objectURI;
|
|
827
705
|
}
|
|
828
706
|
}
|
|
829
|
-
|
|
830
707
|
if (!datatype) {
|
|
831
708
|
if (typeofAtt && !aboutAtt) {
|
|
832
709
|
datatype = RDFaProcessor.objectURI;
|
|
833
710
|
content = typedResource;
|
|
834
711
|
} else {
|
|
835
712
|
content = current.textContent;
|
|
836
|
-
|
|
837
713
|
if (this.inHTMLMode && current.localName === 'time') {
|
|
838
714
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
|
839
715
|
}
|
|
840
|
-
|
|
841
716
|
if (!datatype) {
|
|
842
717
|
datatype = RDFaProcessor.PlainLiteralURI;
|
|
843
718
|
}
|
|
844
719
|
}
|
|
845
720
|
}
|
|
846
|
-
|
|
847
721
|
values = this.tokenize(propertyAtt.value);
|
|
848
|
-
|
|
849
722
|
for (var _i13 = 0; _i13 < values.length; _i13++) {
|
|
850
723
|
var _predicate2 = this.parsePredicate(values[_i13], vocabulary, context.terms, prefixes, base);
|
|
851
|
-
|
|
852
724
|
if (_predicate2) {
|
|
853
725
|
if (inlistAtt) {
|
|
854
726
|
var _list3 = listMapping[_predicate2];
|
|
855
|
-
|
|
856
727
|
if (!_list3) {
|
|
857
728
|
_list3 = [];
|
|
858
729
|
listMapping[_predicate2] = _list3;
|
|
859
730
|
}
|
|
860
|
-
|
|
861
731
|
_list3.push(datatype === RDFaProcessor.XMLLiteralURI || datatype === RDFaProcessor.HTMLLiteralURI ? {
|
|
862
732
|
type: datatype,
|
|
863
733
|
value: current.childNodes
|
|
@@ -877,14 +747,14 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
877
747
|
type: datatype || RDFaProcessor.PlainLiteralURI,
|
|
878
748
|
value: content,
|
|
879
749
|
language: language
|
|
880
|
-
});
|
|
750
|
+
});
|
|
751
|
+
// console.log(newSubject+" "+predicate+"="+content)
|
|
881
752
|
}
|
|
882
753
|
}
|
|
883
754
|
}
|
|
884
755
|
}
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
|
|
756
|
+
}
|
|
757
|
+
// Sequence Step 12: complete incomplete triples with new subject
|
|
888
758
|
if (newSubject && !skip) {
|
|
889
759
|
for (var _i14 = 0; _i14 < context.incomplete.length; _i14++) {
|
|
890
760
|
if (context.incomplete[_i14].list) {
|
|
@@ -909,15 +779,13 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
909
779
|
}
|
|
910
780
|
}
|
|
911
781
|
}
|
|
912
|
-
|
|
913
782
|
var childContext = null;
|
|
914
783
|
var listSubject = newSubject;
|
|
915
|
-
|
|
916
784
|
if (skip) {
|
|
917
785
|
// TODO: should subject be null?
|
|
918
|
-
childContext = this.push(context, context.subject);
|
|
786
|
+
childContext = this.push(context, context.subject);
|
|
787
|
+
// TODO: should the entObject be passed along? If not, then intermediary children will keep properties from being associated with incomplete triples.
|
|
919
788
|
// TODO: Verify: if the current baseURI has changed and the parentObject is the parent's base URI, then the baseURI should change
|
|
920
|
-
|
|
921
789
|
childContext.parentObject = removeHash(current.parentNode.baseURI) === context.parentObject ? removeHash(current.baseURI) : context.parentObject;
|
|
922
790
|
childContext.incomplete = context.incomplete;
|
|
923
791
|
childContext.language = language;
|
|
@@ -928,19 +796,16 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
928
796
|
childContext.parentObject = currentObjectResource || newSubject || context.subject;
|
|
929
797
|
childContext.prefixes = prefixes;
|
|
930
798
|
childContext.incomplete = incomplete;
|
|
931
|
-
|
|
932
799
|
if (currentObjectResource) {
|
|
933
800
|
// console.log("Generating new list mapping for "+currentObjectResource)
|
|
934
801
|
listSubject = currentObjectResource;
|
|
935
802
|
listMapping = {};
|
|
936
803
|
listMappingDifferent = true;
|
|
937
804
|
}
|
|
938
|
-
|
|
939
805
|
childContext.listMapping = listMapping;
|
|
940
806
|
childContext.language = language;
|
|
941
807
|
childContext.vocabulary = vocabulary;
|
|
942
808
|
}
|
|
943
|
-
|
|
944
809
|
if (listMappingDifferent) {
|
|
945
810
|
// console.log("Pushing list parent "+current.localName)
|
|
946
811
|
queue.unshift({
|
|
@@ -950,7 +815,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
950
815
|
listMapping: listMapping
|
|
951
816
|
});
|
|
952
817
|
}
|
|
953
|
-
|
|
954
818
|
for (var child = current.lastChild; child; child = child.previousSibling) {
|
|
955
819
|
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
956
820
|
// console.log("Pushing child "+child.localName)
|
|
@@ -962,11 +826,9 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
962
826
|
}
|
|
963
827
|
}
|
|
964
828
|
}
|
|
965
|
-
|
|
966
829
|
if (this.inHTMLMode) {
|
|
967
830
|
this.copyProperties();
|
|
968
831
|
}
|
|
969
|
-
|
|
970
832
|
for (var _i15 = 0; _i15 < this.finishedHandlers.length; _i15++) {
|
|
971
833
|
this.finishedHandlers[_i15](node);
|
|
972
834
|
}
|
|
@@ -1032,8 +894,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1032
894
|
}, {
|
|
1033
895
|
key: "setInitialContext",
|
|
1034
896
|
value: function setInitialContext() {
|
|
1035
|
-
this.vocabulary = null;
|
|
1036
|
-
|
|
897
|
+
this.vocabulary = null;
|
|
898
|
+
// By default, the prefixes are terms are loaded to the RDFa 1.1. standard within the graph constructor
|
|
1037
899
|
this.langAttributes = [{
|
|
1038
900
|
namespaceURI: 'http://www.w3.org/XML/1998/namespace',
|
|
1039
901
|
localName: 'lang'
|
|
@@ -1051,8 +913,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1051
913
|
}, {
|
|
1052
914
|
namespaceURI: null,
|
|
1053
915
|
localName: 'lang'
|
|
1054
|
-
}];
|
|
1055
|
-
|
|
916
|
+
}];
|
|
917
|
+
// From http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
|
|
1056
918
|
this.target.graph.terms['alternate'] = 'http://www.w3.org/1999/xhtml/vocab#alternate';
|
|
1057
919
|
this.target.graph.terms['appendix'] = 'http://www.w3.org/1999/xhtml/vocab#appendix';
|
|
1058
920
|
this.target.graph.terms['bookmark'] = 'http://www.w3.org/1999/xhtml/vocab#bookmark';
|
|
@@ -1077,8 +939,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1077
939
|
this.target.graph.terms['start'] = 'http://www.w3.org/1999/xhtml/vocab#start';
|
|
1078
940
|
this.target.graph.terms['top'] = 'http://www.w3.org/1999/xhtml/vocab#top';
|
|
1079
941
|
this.target.graph.terms['up'] = 'http://www.w3.org/1999/xhtml/vocab#up';
|
|
1080
|
-
this.target.graph.terms['p3pv1'] = 'http://www.w3.org/1999/xhtml/vocab#p3pv1';
|
|
1081
|
-
|
|
942
|
+
this.target.graph.terms['p3pv1'] = 'http://www.w3.org/1999/xhtml/vocab#p3pv1';
|
|
943
|
+
// other
|
|
1082
944
|
this.target.graph.terms['related'] = 'http://www.w3.org/1999/xhtml/vocab#related';
|
|
1083
945
|
this.target.graph.terms['role'] = 'http://www.w3.org/1999/xhtml/vocab#role';
|
|
1084
946
|
this.target.graph.terms['transformation'] = 'http://www.w3.org/1999/xhtml/vocab#transformation';
|
|
@@ -1099,36 +961,27 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1099
961
|
key: "toRDFNodeObject",
|
|
1100
962
|
value: function toRDFNodeObject(x) {
|
|
1101
963
|
var _this = this;
|
|
1102
|
-
|
|
1103
964
|
if (typeof x === 'undefined') return undefined;
|
|
1104
|
-
|
|
1105
965
|
if (typeof x === 'string') {
|
|
1106
966
|
if (x.substring(0, 2) === '_:') {
|
|
1107
967
|
if (typeof this.blankNodes[x.substring(2)] === 'undefined') {
|
|
1108
968
|
this.blankNodes[x.substring(2)] = new _blankNode.default(x.substring(2));
|
|
1109
969
|
}
|
|
1110
|
-
|
|
1111
970
|
return this.blankNodes[x.substring(2)];
|
|
1112
971
|
}
|
|
1113
|
-
|
|
1114
972
|
return _canonicalDataFactory.default.namedNode(x);
|
|
1115
973
|
}
|
|
1116
|
-
|
|
1117
974
|
switch (x.type) {
|
|
1118
975
|
case RDFaProcessor.objectURI:
|
|
1119
976
|
if (x.value.substring(0, 2) === '_:') {
|
|
1120
977
|
if (typeof this.blankNodes[x.value.substring(2)] === 'undefined') {
|
|
1121
978
|
this.blankNodes[x.value.substring(2)] = new _blankNode.default(x.value.substring(2));
|
|
1122
979
|
}
|
|
1123
|
-
|
|
1124
980
|
return this.blankNodes[x.value.substring(2)];
|
|
1125
981
|
}
|
|
1126
|
-
|
|
1127
982
|
return _canonicalDataFactory.default.namedNode(x.value);
|
|
1128
|
-
|
|
1129
983
|
case RDFaProcessor.PlainLiteralURI:
|
|
1130
984
|
return new _literal.default(x.value, x.language || '');
|
|
1131
|
-
|
|
1132
985
|
case RDFaProcessor.XMLLiteralURI:
|
|
1133
986
|
case RDFaProcessor.HTMLLiteralURI:
|
|
1134
987
|
var string = '';
|
|
@@ -1136,7 +989,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1136
989
|
string += Util.domToString(x.value[i], _this.htmlOptions);
|
|
1137
990
|
});
|
|
1138
991
|
return new _literal.default(string, '', new _namedNode.default(x.type));
|
|
1139
|
-
|
|
1140
992
|
default:
|
|
1141
993
|
return new _literal.default(x.value, '', new _namedNode.default(x.type));
|
|
1142
994
|
}
|
|
@@ -1151,8 +1003,8 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1151
1003
|
value: function parseRDFaDOM(dom, kb, base) {
|
|
1152
1004
|
var p = new RDFaProcessor(kb, {
|
|
1153
1005
|
'base': base
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1006
|
+
});
|
|
1007
|
+
// Cannot assign to read only property 'baseURI' of object '#<XMLDocument>':
|
|
1156
1008
|
if (!dom.baseURI) {
|
|
1157
1009
|
// Note this became a read-only attribute some time before 2018
|
|
1158
1010
|
dom.baseURI = base; // oinly set if not already set
|
|
@@ -1175,7 +1027,6 @@ var RDFaProcessor = /*#__PURE__*/function () {
|
|
|
1175
1027
|
}]);
|
|
1176
1028
|
return RDFaProcessor;
|
|
1177
1029
|
}();
|
|
1178
|
-
|
|
1179
1030
|
exports.default = RDFaProcessor;
|
|
1180
1031
|
RDFaProcessor.XMLLiteralURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral';
|
|
1181
1032
|
RDFaProcessor.HTMLLiteralURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML';
|
|
@@ -1185,6 +1036,7 @@ RDFaProcessor.typeURI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
|
|
|
1185
1036
|
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]";
|
|
1186
1037
|
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_]";
|
|
1187
1038
|
RDFaProcessor.NCNAME = new RegExp('^' + RDFaProcessor.nameStartChar + RDFaProcessor.nameChar + '*$');
|
|
1039
|
+
|
|
1188
1040
|
/*
|
|
1189
1041
|
RDFaProcessor.prototype.resolveAndNormalize = function(base,href) {
|
|
1190
1042
|
var u = base.resolve(href)
|