@lblod/graph-rdfa-processor 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _uriResolver = _interopRequireDefault(require("./uri-resolver"));
9
+
10
+ var _node = _interopRequireDefault(require("./node"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15
+
16
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
+
18
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19
+
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21
+
22
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23
+
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+
26
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
+
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
+
30
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+
32
+ var RDFaProcessor =
33
+ /*#__PURE__*/
34
+ function (_URIResolver) {
35
+ _inherits(RDFaProcessor, _URIResolver);
36
+
37
+ function RDFaProcessor(targetObject) {
38
+ var _this;
39
+
40
+ _classCallCheck(this, RDFaProcessor);
41
+
42
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(RDFaProcessor).call(this));
43
+
44
+ if (targetObject) {
45
+ _this.target = targetObject;
46
+ } else {
47
+ _this.target = {
48
+ graph: {
49
+ subjects: {},
50
+ prefixes: {},
51
+ terms: {}
52
+ }
53
+ };
54
+ }
55
+
56
+ _this.theOne = "_:" + new Date().getTime();
57
+ _this.language = null;
58
+ _this.vocabulary = null;
59
+ _this.blankCounter = 0;
60
+ _this.langAttributes = [{
61
+ namespaceURI: "http://www.w3.org/XML/1998/namespace",
62
+ localName: "lang"
63
+ }];
64
+ _this.inXHTMLMode = false;
65
+ _this.absURIRE = /[\w\_\-]+:\S+/;
66
+ _this.finishedHandlers = [];
67
+
68
+ _this.init();
69
+
70
+ return _this;
71
+ }
72
+
73
+ _createClass(RDFaProcessor, [{
74
+ key: "newBlankNode",
75
+ value: function newBlankNode() {
76
+ this.blankCounter++;
77
+ return "_:" + this.blankCounter;
78
+ }
79
+ }, {
80
+ key: "tokenize",
81
+ value: function tokenize(str) {
82
+ return RDFaProcessor.trim(str).split(/\s+/);
83
+ }
84
+ }, {
85
+ key: "parseSafeCURIEOrCURIEOrURI",
86
+ value: function parseSafeCURIEOrCURIEOrURI(value, prefixes, base) {
87
+ value = RDFaProcessor.trim(value);
88
+
89
+ if (value.charAt(0) == "[" && value.charAt(value.length - 1) == "]") {
90
+ value = value.substring(1, value.length - 1);
91
+ value = value.trim(value);
92
+
93
+ if (value.length == 0) {
94
+ return null;
95
+ }
96
+
97
+ if (value == "_:") {
98
+ // the one node
99
+ return this.theOne;
100
+ }
101
+
102
+ return this.parseCURIE(value, prefixes, base);
103
+ } else {
104
+ return this.parseCURIEOrURI(value, prefixes, base);
105
+ }
106
+ }
107
+ }, {
108
+ key: "parseCURIE",
109
+ value: function parseCURIE(value, prefixes, base) {
110
+ var colon = value.indexOf(":");
111
+
112
+ if (colon >= 0) {
113
+ var prefix = value.substring(0, colon);
114
+
115
+ if (prefix == "") {
116
+ // default prefix
117
+ var uri = prefixes[""];
118
+ return uri ? uri + value.substring(colon + 1) : null;
119
+ } else if (prefix == "_") {
120
+ // blank node
121
+ return "_:" + value.substring(colon + 1);
122
+ } else if (RDFaProcessor.NCNAME.test(prefix)) {
123
+ var uri = prefixes[prefix];
124
+
125
+ if (uri) {
126
+ return uri + value.substring(colon + 1);
127
+ }
128
+ }
129
+ }
130
+
131
+ return null;
132
+ }
133
+ }, {
134
+ key: "parseCURIEOrURI",
135
+ value: function parseCURIEOrURI(value, prefixes, base) {
136
+ var curie = this.parseCURIE(value, prefixes, base);
137
+
138
+ if (curie) {
139
+ return curie;
140
+ }
141
+
142
+ return this.resolveAndNormalize(base, value);
143
+ }
144
+ }, {
145
+ key: "parsePredicate",
146
+ value: function parsePredicate(value, defaultVocabulary, terms, prefixes, base, ignoreTerms) {
147
+ if (value == "") {
148
+ return null;
149
+ }
150
+
151
+ var predicate = this.parseTermOrCURIEOrAbsURI(value, defaultVocabulary, ignoreTerms ? null : terms, prefixes, base);
152
+
153
+ if (predicate && predicate.indexOf("_:") == 0) {
154
+ return null;
155
+ }
156
+
157
+ return predicate;
158
+ }
159
+ }, {
160
+ key: "parseTermOrCURIEOrURI",
161
+ value: function parseTermOrCURIEOrURI(value, defaultVocabulary, terms, prefixes, base) {
162
+ //alert("Parsing "+value+" with default vocab "+defaultVocabulary);
163
+ value = RDFaProcessor.trim(value);
164
+ var curie = this.parseCURIE(value, prefixes, base);
165
+
166
+ if (curie) {
167
+ return curie;
168
+ } else {
169
+ var term = terms[value];
170
+
171
+ if (term) {
172
+ return term;
173
+ }
174
+
175
+ var lcvalue = value.toLowerCase();
176
+ term = terms[lcvalue];
177
+
178
+ if (term) {
179
+ return term;
180
+ }
181
+
182
+ if (defaultVocabulary && !this.absURIRE.exec(value)) {
183
+ return defaultVocabulary + value;
184
+ }
185
+ }
186
+
187
+ return this.resolveAndNormalize(base, value);
188
+ }
189
+ }, {
190
+ key: "parseTermOrCURIEOrAbsURI",
191
+ value: function parseTermOrCURIEOrAbsURI(value, defaultVocabulary, terms, prefixes, base) {
192
+ //alert("Parsing "+value+" with default vocab "+defaultVocabulary);
193
+ value = RDFaProcessor.trim(value);
194
+ var curie = this.parseCURIE(value, prefixes, base);
195
+
196
+ if (curie) {
197
+ return curie;
198
+ } else if (terms) {
199
+ if (defaultVocabulary && !this.absURIRE.exec(value)) {
200
+ return defaultVocabulary + value;
201
+ }
202
+
203
+ var term = terms[value];
204
+
205
+ if (term) {
206
+ return term;
207
+ }
208
+
209
+ var lcvalue = value.toLowerCase();
210
+ term = terms[lcvalue];
211
+
212
+ if (term) {
213
+ return term;
214
+ }
215
+ }
216
+
217
+ if (this.absURIRE.exec(value)) {
218
+ return this.resolveAndNormalize(base, value);
219
+ }
220
+
221
+ return null;
222
+ }
223
+ }, {
224
+ key: "resolveAndNormalize",
225
+ value: function resolveAndNormalize(base, href) {
226
+ var u = base.resolve(href);
227
+ var parsed = this.parseURI(u);
228
+ parsed.normalize();
229
+ return parsed.spec;
230
+ }
231
+ }, {
232
+ key: "parsePrefixMappings",
233
+ value: function parsePrefixMappings(str, target) {
234
+ var values = this.tokenize(str);
235
+ var prefix = null;
236
+ var uri = null;
237
+
238
+ for (var i = 0; i < values.length; i++) {
239
+ if (values[i][values[i].length - 1] == ":") {
240
+ prefix = values[i].substring(0, values[i].length - 1);
241
+ } else if (prefix) {
242
+ target[prefix] = this.target.baseURI ? this.target.baseURI.resolve(values[i]) : values[i];
243
+ prefix = null;
244
+ }
245
+ }
246
+ }
247
+ }, {
248
+ key: "copyMappings",
249
+ value: function copyMappings(mappings) {
250
+ var newMappings = {};
251
+
252
+ for (var k in mappings) {
253
+ newMappings[k] = mappings[k];
254
+ }
255
+
256
+ return newMappings;
257
+ }
258
+ }, {
259
+ key: "ancestorPath",
260
+ value: function ancestorPath(node) {
261
+ var path = "";
262
+
263
+ while (node && node.nodeType != _node.default.DOCUMENT_NODE) {
264
+ path = "/" + node.localName + path;
265
+ node = node.parentNode;
266
+ }
267
+
268
+ return path;
269
+ }
270
+ }, {
271
+ key: "setContext",
272
+ value: function setContext(node) {
273
+ // We only recognized XHTML+RDFa 1.1 if the version is set propertyly
274
+ if (node.localName == "html" && node.getAttribute("version") == "XHTML+RDFa 1.1") {
275
+ this.setXHTMLContext();
276
+ } else if (node.localName == "html" || node.namespaceURI == "http://www.w3.org/1999/xhtml") {
277
+ if (node.ownerDocument.doctype) {
278
+ if (node.ownerDocument.doctype.publicId == "-//W3C//DTD XHTML+RDFa 1.0//EN" && node.ownerDocument.doctype.systemId == "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd") {
279
+ console.log("WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode.");
280
+ this.setHTMLContext();
281
+ } else if (node.ownerDocument.doctype.publicId == "-//W3C//DTD XHTML+RDFa 1.1//EN" && node.ownerDocument.doctype.systemId == "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd") {
282
+ this.setXHTMLContext();
283
+ } else {
284
+ this.setHTMLContext();
285
+ }
286
+ } else {
287
+ this.setHTMLContext();
288
+ }
289
+ } else {
290
+ this.setXMLContext();
291
+ }
292
+ }
293
+ }, {
294
+ key: "setInitialContext",
295
+ value: function setInitialContext() {
296
+ this.vocabulary = null; // By default, the prefixes are terms are loaded to the RDFa 1.1. standard within the graph constructor
297
+
298
+ this.langAttributes = [{
299
+ namespaceURI: "http://www.w3.org/XML/1998/namespace",
300
+ localName: "lang"
301
+ }];
302
+ }
303
+ }, {
304
+ key: "setXMLContext",
305
+ value: function setXMLContext() {
306
+ this.setInitialContext();
307
+ this.inXHTMLMode = false;
308
+ this.inHTMLMode = false;
309
+ }
310
+ }, {
311
+ key: "setHTMLContext",
312
+ value: function setHTMLContext() {
313
+ this.setInitialContext();
314
+ this.langAttributes = [{
315
+ namespaceURI: "http://www.w3.org/XML/1998/namespace",
316
+ localName: "lang"
317
+ }, {
318
+ namespaceURI: null,
319
+ localName: "lang"
320
+ }];
321
+ this.inXHTMLMode = false;
322
+ this.inHTMLMode = true;
323
+ }
324
+ }, {
325
+ key: "setXHTMLContext",
326
+ value: function setXHTMLContext() {
327
+ this.setInitialContext();
328
+ this.inXHTMLMode = true;
329
+ this.inHTMLMode = false;
330
+ this.langAttributes = [{
331
+ namespaceURI: "http://www.w3.org/XML/1998/namespace",
332
+ localName: "lang"
333
+ }, {
334
+ namespaceURI: null,
335
+ localName: "lang"
336
+ }]; // From http://www.w3.org/2011/rdfa-context/xhtml-rdfa-1.1
337
+
338
+ this.target.graph.terms["alternate"] = "http://www.w3.org/1999/xhtml/vocab#alternate";
339
+ this.target.graph.terms["appendix"] = "http://www.w3.org/1999/xhtml/vocab#appendix";
340
+ this.target.graph.terms["bookmark"] = "http://www.w3.org/1999/xhtml/vocab#bookmark";
341
+ this.target.graph.terms["cite"] = "http://www.w3.org/1999/xhtml/vocab#cite";
342
+ this.target.graph.terms["chapter"] = "http://www.w3.org/1999/xhtml/vocab#chapter";
343
+ this.target.graph.terms["contents"] = "http://www.w3.org/1999/xhtml/vocab#contents";
344
+ this.target.graph.terms["copyright"] = "http://www.w3.org/1999/xhtml/vocab#copyright";
345
+ this.target.graph.terms["first"] = "http://www.w3.org/1999/xhtml/vocab#first";
346
+ this.target.graph.terms["glossary"] = "http://www.w3.org/1999/xhtml/vocab#glossary";
347
+ this.target.graph.terms["help"] = "http://www.w3.org/1999/xhtml/vocab#help";
348
+ this.target.graph.terms["icon"] = "http://www.w3.org/1999/xhtml/vocab#icon";
349
+ this.target.graph.terms["index"] = "http://www.w3.org/1999/xhtml/vocab#index";
350
+ this.target.graph.terms["last"] = "http://www.w3.org/1999/xhtml/vocab#last";
351
+ this.target.graph.terms["license"] = "http://www.w3.org/1999/xhtml/vocab#license";
352
+ this.target.graph.terms["meta"] = "http://www.w3.org/1999/xhtml/vocab#meta";
353
+ this.target.graph.terms["next"] = "http://www.w3.org/1999/xhtml/vocab#next";
354
+ this.target.graph.terms["prev"] = "http://www.w3.org/1999/xhtml/vocab#prev";
355
+ this.target.graph.terms["previous"] = "http://www.w3.org/1999/xhtml/vocab#previous";
356
+ this.target.graph.terms["section"] = "http://www.w3.org/1999/xhtml/vocab#section";
357
+ this.target.graph.terms["stylesheet"] = "http://www.w3.org/1999/xhtml/vocab#stylesheet";
358
+ this.target.graph.terms["subsection"] = "http://www.w3.org/1999/xhtml/vocab#subsection";
359
+ this.target.graph.terms["start"] = "http://www.w3.org/1999/xhtml/vocab#start";
360
+ this.target.graph.terms["top"] = "http://www.w3.org/1999/xhtml/vocab#top";
361
+ this.target.graph.terms["up"] = "http://www.w3.org/1999/xhtml/vocab#up";
362
+ this.target.graph.terms["p3pv1"] = "http://www.w3.org/1999/xhtml/vocab#p3pv1"; // other
363
+
364
+ this.target.graph.terms["related"] = "http://www.w3.org/1999/xhtml/vocab#related";
365
+ this.target.graph.terms["role"] = "http://www.w3.org/1999/xhtml/vocab#role";
366
+ this.target.graph.terms["transformation"] = "http://www.w3.org/1999/xhtml/vocab#transformation";
367
+ }
368
+ }, {
369
+ key: "init",
370
+ value: function init() {}
371
+ }, {
372
+ key: "newSubjectOrigin",
373
+ value: function newSubjectOrigin(origin, subject) {}
374
+ }, {
375
+ key: "addTriple",
376
+ value: function addTriple(origin, subject, predicate, object) {}
377
+ }, {
378
+ key: "process",
379
+ value: function process(node, options) {
380
+ if (node.nodeType == _node.default.DOCUMENT_NODE) {
381
+ node = node.documentElement;
382
+ this.setContext(node);
383
+ } else if (node.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
384
+ this.setContext(node);
385
+ }
386
+
387
+ var queue = []; // Fix for Firefox that includes the hash in the base URI
388
+
389
+ var removeHash = function removeHash(baseURI) {
390
+ var hash = baseURI.indexOf("#");
391
+
392
+ if (hash >= 0) {
393
+ baseURI = baseURI.substring(0, hash);
394
+ }
395
+
396
+ if (options && options.baseURIMap) {
397
+ baseURI = options.baseURIMap(baseURI);
398
+ }
399
+
400
+ if (baseURI == "about:blank") {
401
+ baseURI = options.baseURI;
402
+ }
403
+
404
+ return baseURI;
405
+ };
406
+
407
+ queue.push({
408
+ current: node,
409
+ context: this.push(null, removeHash(node.baseURI))
410
+ });
411
+
412
+ while (queue.length > 0) {
413
+ var item = queue.shift();
414
+
415
+ if (item.parent) {
416
+ // Sequence Step 14: list triple generation
417
+ if (item.context.parent && item.context.parent.listMapping == item.listMapping) {
418
+ // Skip a child context with exactly the same mapping
419
+ continue;
420
+ } //console.log("Generating lists for "+item.subject+", tag "+item.parent.localName);
421
+
422
+
423
+ for (var predicate in item.listMapping) {
424
+ var list = item.listMapping[predicate];
425
+
426
+ if (list.length == 0) {
427
+ this.addTriple(item.parent, item.subject, predicate, {
428
+ type: RDFaProcessor.objectURI,
429
+ value: "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
430
+ });
431
+ continue;
432
+ }
433
+
434
+ var bnodes = [];
435
+
436
+ for (var i = 0; i < list.length; i++) {
437
+ bnodes.push(this.newBlankNode()); //this.newSubject(item.parent,bnodes[i]);
438
+ }
439
+
440
+ for (var i = 0; i < bnodes.length; i++) {
441
+ this.addTriple(item.parent, bnodes[i], "http://www.w3.org/1999/02/22-rdf-syntax-ns#first", list[i]);
442
+ this.addTriple(item.parent, bnodes[i], "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest", {
443
+ type: RDFaProcessor.objectURI,
444
+ value: i + 1 < bnodes.length ? bnodes[i + 1] : "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
445
+ });
446
+ }
447
+
448
+ this.addTriple(item.parent, item.subject, predicate, {
449
+ type: RDFaProcessor.objectURI,
450
+ value: bnodes[0]
451
+ });
452
+ }
453
+
454
+ continue;
455
+ }
456
+
457
+ var current = item.current;
458
+ var context = item.context; //console.log("Tag: "+current.localName+", listMapping="+JSON.stringify(context.listMapping));
459
+ // Sequence Step 1
460
+
461
+ var skip = false;
462
+ var newSubject = null;
463
+ var currentObjectResource = null;
464
+ var typedResource = null;
465
+ var prefixes = context.prefixes;
466
+ var prefixesCopied = false;
467
+ var incomplete = [];
468
+ var listMapping = context.listMapping;
469
+ var listMappingDifferent = context.parent ? false : true;
470
+ var language = context.language;
471
+ var vocabulary = context.vocabulary; // TODO: the "base" element may be used for HTML+RDFa 1.1
472
+
473
+ var base;
474
+
475
+ if (!current.baseURI) {
476
+ if (this.target.baseURI) {
477
+ base = this.target.baseURI;
478
+ } else {
479
+ throw new Error("node.baseURI was null as baseURI must be specified as an option");
480
+ }
481
+ } else if (current.baseURI === "about:blank") {
482
+ if (this.target.baseURI) {
483
+ base = this.target.baseURI;
484
+ } else {
485
+ throw new Error("node.baseURI is about:blank a valid URL must be provided with the baseURI option. If you use JSDOM call it with an `url` parameter or, set the baseURI option of this library");
486
+ }
487
+ } else {
488
+ base = this.parseURI(removeHash(current.baseURI));
489
+ }
490
+
491
+ current.item = null; // Sequence Step 2: set the default vocabulary
492
+
493
+ var vocabAtt = current.getAttributeNode("vocab");
494
+
495
+ if (vocabAtt) {
496
+ var value = RDFaProcessor.trim(vocabAtt.value);
497
+
498
+ if (value.length > 0) {
499
+ vocabulary = value;
500
+ var baseSubject = base.spec; //this.newSubject(current,baseSubject);
501
+
502
+ this.addTriple(current, baseSubject, "http://www.w3.org/ns/rdfa#usesVocabulary", {
503
+ type: RDFaProcessor.objectURI,
504
+ value: vocabulary
505
+ });
506
+ } else {
507
+ vocabulary = this.vocabulary;
508
+ }
509
+ } // Sequence Step 3: IRI mappings
510
+ // handle xmlns attributes
511
+
512
+
513
+ for (var i = 0; i < current.attributes.length; i++) {
514
+ var att = current.attributes[i]; //if (att.namespaceURI=="http://www.w3.org/2000/xmlns/") {
515
+
516
+ if (att.name.charAt(0) == "x" && att.name.indexOf("xmlns:") == 0) {
517
+ if (!prefixesCopied) {
518
+ prefixes = this.copyMappings(prefixes);
519
+ prefixesCopied = true;
520
+ }
521
+
522
+ var prefix = att.name.substring(6); // TODO: resolve relative?
523
+
524
+ var ref = RDFaProcessor.trim(att.value);
525
+ prefixes[prefix] = this.target.baseURI ? this.target.baseURI.resolve(ref) : ref;
526
+ }
527
+ } // Handle prefix mappings (@prefix)
528
+
529
+
530
+ var prefixAtt = current.getAttributeNode("prefix");
531
+
532
+ if (prefixAtt) {
533
+ if (!prefixesCopied) {
534
+ prefixes = this.copyMappings(prefixes);
535
+ prefixesCopied = true;
536
+ }
537
+
538
+ this.parsePrefixMappings(prefixAtt.value, prefixes);
539
+ } // Sequence Step 4: language
540
+
541
+
542
+ var xmlLangAtt = null;
543
+
544
+ for (var i = 0; !xmlLangAtt && i < this.langAttributes.length; i++) {
545
+ xmlLangAtt = current.getAttributeNodeNS(this.langAttributes[i].namespaceURI, this.langAttributes[i].localName);
546
+ }
547
+
548
+ if (xmlLangAtt) {
549
+ var value = RDFaProcessor.trim(xmlLangAtt.value);
550
+
551
+ if (value.length > 0) {
552
+ language = value;
553
+ } else {
554
+ language = null;
555
+ }
556
+ }
557
+
558
+ var relAtt = current.getAttributeNode("rel");
559
+ var revAtt = current.getAttributeNode("rev");
560
+ var typeofAtt = current.getAttributeNode("typeof");
561
+ var propertyAtt = current.getAttributeNode("property");
562
+ var datatypeAtt = current.getAttributeNode("datatype");
563
+ var datetimeAtt = this.inHTMLMode ? current.getAttributeNode("datetime") : null;
564
+ var contentAtt = current.getAttributeNode("content");
565
+ var aboutAtt = current.getAttributeNode("about");
566
+ var srcAtt = current.getAttributeNode("src");
567
+ var resourceAtt = current.getAttributeNode("resource");
568
+ var hrefAtt = current.getAttributeNode("href");
569
+ var inlistAtt = current.getAttributeNode("inlist");
570
+ var relAttPredicates = [];
571
+
572
+ if (relAtt) {
573
+ var values = this.tokenize(relAtt.value);
574
+
575
+ for (var i = 0; i < values.length; i++) {
576
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt != null);
577
+
578
+ if (predicate) {
579
+ relAttPredicates.push(predicate);
580
+ }
581
+ }
582
+ }
583
+
584
+ var revAttPredicates = [];
585
+
586
+ if (revAtt) {
587
+ var values = this.tokenize(revAtt.value);
588
+
589
+ for (var i = 0; i < values.length; i++) {
590
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt != null);
591
+
592
+ if (predicate) {
593
+ revAttPredicates.push(predicate);
594
+ }
595
+ }
596
+ } // Section 3.1, bullet 7
597
+
598
+
599
+ if (this.inHTMLMode && (relAtt != null || revAtt != null) && propertyAtt != null) {
600
+ if (relAttPredicates.length == 0) {
601
+ relAtt = null;
602
+ }
603
+
604
+ if (revAttPredicates.length == 0) {
605
+ revAtt = null;
606
+ }
607
+ }
608
+
609
+ if (relAtt || revAtt) {
610
+ // Sequence Step 6: establish new subject and value
611
+ if (aboutAtt) {
612
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
613
+ }
614
+
615
+ if (typeofAtt) {
616
+ typedResource = newSubject;
617
+ }
618
+
619
+ if (!newSubject) {
620
+ if (current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
621
+ newSubject = removeHash(current.baseURI);
622
+ } else if (context.parentObject) {
623
+ // 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
624
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
625
+ }
626
+ }
627
+
628
+ if (resourceAtt) {
629
+ currentObjectResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
630
+ }
631
+
632
+ if (!currentObjectResource) {
633
+ if (hrefAtt) {
634
+ currentObjectResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
635
+ } else if (srcAtt) {
636
+ currentObjectResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
637
+ } else if (typeofAtt && !aboutAtt && !(this.inXHTMLMode && (current.localName == "head" || current.localName == "body"))) {
638
+ currentObjectResource = this.newBlankNode();
639
+ }
640
+ }
641
+
642
+ if (typeofAtt && !aboutAtt && this.inXHTMLMode && (current.localName == "head" || current.localName == "body")) {
643
+ typedResource = newSubject;
644
+ } else if (typeofAtt && !aboutAtt) {
645
+ typedResource = currentObjectResource;
646
+ }
647
+ } else if (propertyAtt && !contentAtt && !datatypeAtt) {
648
+ // Sequence Step 5.1: establish a new subject
649
+ if (aboutAtt) {
650
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
651
+
652
+ if (typeofAtt) {
653
+ typedResource = newSubject;
654
+ }
655
+ }
656
+
657
+ if (!newSubject && current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
658
+ newSubject = removeHash(current.baseURI);
659
+
660
+ if (typeofAtt) {
661
+ typedResource = newSubject;
662
+ }
663
+ } else if (!newSubject && context.parentObject) {
664
+ // 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
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
666
+ }
667
+
668
+ if (typeofAtt && !typedResource) {
669
+ if (resourceAtt) {
670
+ typedResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
671
+ }
672
+
673
+ if (!typedResource && hrefAtt) {
674
+ typedResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
675
+ }
676
+
677
+ if (!typedResource && srcAtt) {
678
+ typedResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
679
+ }
680
+
681
+ if (!typedResource && (this.inXHTMLMode || this.inHTMLMode) && (current.localName == "head" || current.localName == "body")) {
682
+ typedResource = newSubject;
683
+ }
684
+
685
+ if (!typedResource) {
686
+ typedResource = this.newBlankNode();
687
+ }
688
+
689
+ currentObjectResource = typedResource;
690
+ } //console.log(current.localName+", newSubject="+newSubject+", typedResource="+typedResource+", currentObjectResource="+currentObjectResource);
691
+
692
+ } else {
693
+ // Sequence Step 5.2: establish a new subject
694
+ if (aboutAtt) {
695
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
696
+ }
697
+
698
+ if (!newSubject && resourceAtt) {
699
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
700
+ }
701
+
702
+ if (!newSubject && hrefAtt) {
703
+ newSubject = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
704
+ }
705
+
706
+ if (!newSubject && srcAtt) {
707
+ newSubject = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
708
+ }
709
+
710
+ if (!newSubject) {
711
+ if (current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
712
+ newSubject = removeHash(current.baseURI);
713
+ } else if ((this.inXHTMLMode || this.inHTMLMode) && (current.localName == "head" || current.localName == "body")) {
714
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
715
+ } else if (typeofAtt) {
716
+ newSubject = this.newBlankNode();
717
+ } else if (context.parentObject) {
718
+ // 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
719
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
720
+
721
+ if (!propertyAtt) {
722
+ skip = true;
723
+ }
724
+ }
725
+ }
726
+
727
+ if (typeofAtt) {
728
+ typedResource = newSubject;
729
+ }
730
+ } //console.log(current.tagName+": newSubject="+newSubject+", currentObjectResource="+currentObjectResource+", typedResource="+typedResource+", skip="+skip);
731
+
732
+
733
+ var rdfaData = null;
734
+
735
+ if (newSubject) {
736
+ //this.newSubject(current,newSubject);
737
+ if (aboutAtt || resourceAtt || typedResource) {
738
+ var id = newSubject;
739
+
740
+ if (typeofAtt && !aboutAtt && !resourceAtt && currentObjectResource) {
741
+ id = currentObjectResource;
742
+ } //console.log("Setting data attribute for "+current.localName+" for subject "+id);
743
+
744
+
745
+ this.newSubjectOrigin(current, id);
746
+ }
747
+ } // Sequence Step 7: generate type triple
748
+
749
+
750
+ if (typedResource) {
751
+ var values = this.tokenize(typeofAtt.value);
752
+
753
+ for (var i = 0; i < values.length; i++) {
754
+ var object = this.parseTermOrCURIEOrAbsURI(values[i], vocabulary, context.terms, prefixes, base);
755
+
756
+ if (object) {
757
+ this.addTriple(current, typedResource, RDFaProcessor.typeURI, {
758
+ type: RDFaProcessor.objectURI,
759
+ value: object
760
+ });
761
+ }
762
+ }
763
+ } // Sequence Step 8: new list mappings if there is a new subject
764
+ //console.log("Step 8: newSubject="+newSubject+", context.parentObject="+context.parentObject);
765
+
766
+
767
+ if (newSubject && newSubject != context.parentObject) {
768
+ //console.log("Generating new list mapping for "+newSubject);
769
+ listMapping = {};
770
+ listMappingDifferent = true;
771
+ } // Sequence Step 9: generate object triple
772
+
773
+
774
+ if (currentObjectResource) {
775
+ if (relAtt && inlistAtt) {
776
+ for (var i = 0; i < relAttPredicates.length; i++) {
777
+ var list = listMapping[relAttPredicates[i]];
778
+
779
+ if (!list) {
780
+ list = [];
781
+ listMapping[relAttPredicates[i]] = list;
782
+ }
783
+
784
+ list.push({
785
+ type: RDFaProcessor.objectURI,
786
+ value: currentObjectResource
787
+ });
788
+ }
789
+ } else if (relAtt) {
790
+ for (var i = 0; i < relAttPredicates.length; i++) {
791
+ this.addTriple(current, newSubject, relAttPredicates[i], {
792
+ type: RDFaProcessor.objectURI,
793
+ value: currentObjectResource
794
+ });
795
+ }
796
+ }
797
+
798
+ if (revAtt) {
799
+ for (var i = 0; i < revAttPredicates.length; i++) {
800
+ this.addTriple(current, currentObjectResource, revAttPredicates[i], {
801
+ type: RDFaProcessor.objectURI,
802
+ value: newSubject
803
+ });
804
+ }
805
+ }
806
+ } else {
807
+ // Sequence Step 10: incomplete triples
808
+ if (newSubject && !currentObjectResource && (relAtt || revAtt)) {
809
+ currentObjectResource = this.newBlankNode(); //alert(current.tagName+": generated blank node, newSubject="+newSubject+" currentObjectResource="+currentObjectResource);
810
+ }
811
+
812
+ if (relAtt && inlistAtt) {
813
+ for (var i = 0; i < relAttPredicates.length; i++) {
814
+ var list = listMapping[relAttPredicates[i]];
815
+
816
+ if (!list) {
817
+ list = [];
818
+ listMapping[predicate] = list;
819
+ } //console.log("Adding incomplete list for "+predicate);
820
+
821
+
822
+ incomplete.push({
823
+ predicate: relAttPredicates[i],
824
+ list: list
825
+ });
826
+ }
827
+ } else if (relAtt) {
828
+ for (var i = 0; i < relAttPredicates.length; i++) {
829
+ incomplete.push({
830
+ predicate: relAttPredicates[i],
831
+ forward: true
832
+ });
833
+ }
834
+ }
835
+
836
+ if (revAtt) {
837
+ for (var i = 0; i < revAttPredicates.length; i++) {
838
+ incomplete.push({
839
+ predicate: revAttPredicates[i],
840
+ forward: false
841
+ });
842
+ }
843
+ }
844
+ } // Step 11: Current property values
845
+
846
+
847
+ if (propertyAtt) {
848
+ var datatype = null;
849
+ var content = null;
850
+
851
+ if (datatypeAtt) {
852
+ datatype = datatypeAtt.value == "" ? RDFaProcessor.PlainLiteralURI : this.parseTermOrCURIEOrAbsURI(datatypeAtt.value, vocabulary, context.terms, prefixes, base);
853
+
854
+ if (datetimeAtt && !contentAtt) {
855
+ content = datetimeAtt.value;
856
+ } else {
857
+ content = datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI ? null : contentAtt ? contentAtt.value : current.textContent;
858
+ }
859
+ } else if (contentAtt) {
860
+ datatype = RDFaProcessor.PlainLiteralURI;
861
+ content = contentAtt.value;
862
+ } else if (datetimeAtt) {
863
+ content = datetimeAtt.value;
864
+ datatype = RDFaProcessor.deriveDateTimeType(content);
865
+
866
+ if (!datatype) {
867
+ datatype = RDFaProcessor.PlainLiteralURI;
868
+ }
869
+ } else if (!relAtt && !revAtt) {
870
+ if (resourceAtt) {
871
+ content = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
872
+ }
873
+
874
+ if (!content && hrefAtt) {
875
+ content = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
876
+ } else if (!content && srcAtt) {
877
+ content = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
878
+ }
879
+
880
+ if (content) {
881
+ datatype = RDFaProcessor.objectURI;
882
+ }
883
+ }
884
+
885
+ if (!datatype) {
886
+ if (typeofAtt && !aboutAtt) {
887
+ datatype = RDFaProcessor.objectURI;
888
+ content = typedResource;
889
+ } else {
890
+ content = current.textContent;
891
+
892
+ if (this.inHTMLMode && current.localName == "time") {
893
+ datatype = RDFaProcessor.deriveDateTimeType(content);
894
+ }
895
+
896
+ if (!datatype) {
897
+ datatype = RDFaProcessor.PlainLiteralURI;
898
+ }
899
+ }
900
+ }
901
+
902
+ var values = this.tokenize(propertyAtt.value);
903
+
904
+ for (var i = 0; i < values.length; i++) {
905
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base);
906
+
907
+ if (predicate) {
908
+ if (inlistAtt) {
909
+ var list = listMapping[predicate];
910
+
911
+ if (!list) {
912
+ list = [];
913
+ listMapping[predicate] = list;
914
+ }
915
+
916
+ list.push(datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI ? {
917
+ type: datatype,
918
+ value: current.childNodes
919
+ } : {
920
+ type: datatype ? datatype : RDFaProcessor.PlainLiteralURI,
921
+ value: content,
922
+ language: language
923
+ });
924
+ } else {
925
+ if (datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI) {
926
+ this.addTriple(current, newSubject, predicate, {
927
+ type: datatype,
928
+ value: current.childNodes
929
+ });
930
+ } else {
931
+ this.addTriple(current, newSubject, predicate, {
932
+ type: datatype ? datatype : RDFaProcessor.PlainLiteralURI,
933
+ value: content,
934
+ language: language
935
+ });
936
+ var specialPredicate = this.target.specialHtmlPredicates.find(function (sp) {
937
+ return sp.source === predicate;
938
+ });
939
+
940
+ if (specialPredicate) {
941
+ this.addTriple(current, newSubject, specialPredicate.target, {
942
+ type: RDFaProcessor.HTMLLiteralURI,
943
+ value: current.childNodes
944
+ });
945
+ } //console.log(newSubject+" "+predicate+"="+content);
946
+
947
+ }
948
+ }
949
+ }
950
+ }
951
+ } // Sequence Step 12: complete incomplete triples with new subject
952
+
953
+
954
+ if (newSubject && !skip) {
955
+ for (var i = 0; i < context.incomplete.length; i++) {
956
+ if (context.incomplete[i].list) {
957
+ //console.log("Adding subject "+newSubject+" to list for "+context.incomplete[i].predicate);
958
+ // TODO: it is unclear what to do here
959
+ context.incomplete[i].list.push({
960
+ type: RDFaProcessor.objectURI,
961
+ value: newSubject
962
+ });
963
+ } else if (context.incomplete[i].forward) {
964
+ //console.log(current.tagName+": completing forward triple "+context.incomplete[i].predicate+" with object="+newSubject);
965
+ this.addTriple(current, context.subject, context.incomplete[i].predicate, {
966
+ type: RDFaProcessor.objectURI,
967
+ value: newSubject
968
+ });
969
+ } else {
970
+ //console.log(current.tagName+": completing reverse triple with object="+context.subject);
971
+ this.addTriple(current, newSubject, context.incomplete[i].predicate, {
972
+ type: RDFaProcessor.objectURI,
973
+ value: context.subject
974
+ });
975
+ }
976
+ }
977
+ }
978
+
979
+ var childContext = null;
980
+ var listSubject = newSubject;
981
+
982
+ if (skip) {
983
+ // TODO: should subject be null?
984
+ childContext = this.push(context, context.subject); // TODO: should the entObject be passed along? If not, then intermediary children will keep properties from being associated with incomplete triples.
985
+ // TODO: Verify: if the current baseURI has changed and the parentObject is the parent's base URI, then the baseURI should change
986
+
987
+ childContext.parentObject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
988
+ childContext.incomplete = context.incomplete;
989
+ childContext.language = language;
990
+ childContext.prefixes = prefixes;
991
+ childContext.vocabulary = vocabulary;
992
+ } else {
993
+ childContext = this.push(context, newSubject);
994
+ childContext.parentObject = currentObjectResource ? currentObjectResource : newSubject ? newSubject : context.subject;
995
+ childContext.prefixes = prefixes;
996
+ childContext.incomplete = incomplete;
997
+
998
+ if (currentObjectResource) {
999
+ //console.log("Generating new list mapping for "+currentObjectResource);
1000
+ listSubject = currentObjectResource;
1001
+ listMapping = {};
1002
+ listMappingDifferent = true;
1003
+ }
1004
+
1005
+ childContext.listMapping = listMapping;
1006
+ childContext.language = language;
1007
+ childContext.vocabulary = vocabulary;
1008
+ }
1009
+
1010
+ if (listMappingDifferent) {
1011
+ //console.log("Pushing list parent "+current.localName);
1012
+ queue.unshift({
1013
+ parent: current,
1014
+ context: context,
1015
+ subject: listSubject,
1016
+ listMapping: listMapping
1017
+ });
1018
+ }
1019
+
1020
+ for (var child = current.lastChild; child; child = child.previousSibling) {
1021
+ if (child.nodeType == _node.default.ELEMENT_NODE) {
1022
+ //console.log("Pushing child "+child.localName);
1023
+ queue.unshift({
1024
+ current: child,
1025
+ context: childContext
1026
+ });
1027
+ }
1028
+ }
1029
+ }
1030
+
1031
+ if (this.inHTMLMode) {
1032
+ this.copyProperties();
1033
+ }
1034
+
1035
+ for (var i = 0; i < this.finishedHandlers.length; i++) {
1036
+ this.finishedHandlers[i](node);
1037
+ }
1038
+ }
1039
+ }, {
1040
+ key: "copyProperties",
1041
+ value: function copyProperties() {}
1042
+ }, {
1043
+ key: "push",
1044
+ value: function push(parent, subject) {
1045
+ return {
1046
+ parent: parent,
1047
+ subject: subject ? subject : parent ? parent.subject : null,
1048
+ parentObject: null,
1049
+ incomplete: [],
1050
+ listMapping: parent ? parent.listMapping : {},
1051
+ language: parent ? parent.language : this.language,
1052
+ prefixes: parent ? parent.prefixes : this.target.graph.prefixes,
1053
+ terms: parent ? parent.terms : this.target.graph.terms,
1054
+ vocabulary: parent ? parent.vocabulary : this.vocabulary
1055
+ };
1056
+ }
1057
+ }]);
1058
+
1059
+ return RDFaProcessor;
1060
+ }(_uriResolver.default);
1061
+
1062
+ exports.default = RDFaProcessor;
1063
+ RDFaProcessor.XMLLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
1064
+ RDFaProcessor.HTMLLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML";
1065
+ RDFaProcessor.PlainLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral";
1066
+ RDFaProcessor.objectURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#object";
1067
+ RDFaProcessor.typeURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
1068
+ 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]";
1069
+ 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_]";
1070
+ RDFaProcessor.NCNAME = new RegExp("^" + RDFaProcessor.nameStartChar + RDFaProcessor.nameChar + "*$");
1071
+
1072
+ RDFaProcessor.trim = function (str) {
1073
+ return str.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
1074
+ };
1075
+
1076
+ RDFaProcessor.dateTimeTypes = [{
1077
+ pattern: /-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,
1078
+ type: "http://www.w3.org/2001/XMLSchema#duration"
1079
+ }, {
1080
+ pattern: /-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,
1081
+ type: "http://www.w3.org/2001/XMLSchema#dateTime"
1082
+ }, {
1083
+ pattern: /-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,
1084
+ type: "http://www.w3.org/2001/XMLSchema#date"
1085
+ }, {
1086
+ pattern: /(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,
1087
+ type: "http://www.w3.org/2001/XMLSchema#time"
1088
+ }, {
1089
+ pattern: /-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,
1090
+ type: "http://www.w3.org/2001/XMLSchema#gYearMonth"
1091
+ }, {
1092
+ pattern: /-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,
1093
+ type: "http://www.w3.org/2001/XMLSchema#gYear"
1094
+ }];
1095
+
1096
+ RDFaProcessor.deriveDateTimeType = function (value) {
1097
+ for (var i = 0; i < RDFaProcessor.dateTimeTypes.length; i++) {
1098
+ //console.log("Checking "+value+" against "+RDFaProcessor.dateTimeTypes[i].type);
1099
+ var matched = RDFaProcessor.dateTimeTypes[i].pattern.exec(value);
1100
+
1101
+ if (matched && matched[0].length == value.length) {
1102
+ //console.log("Matched!");
1103
+ return RDFaProcessor.dateTimeTypes[i].type;
1104
+ }
1105
+ }
1106
+
1107
+ return null;
1108
+ };
1109
+
1110
+ module.exports = exports.default;