@lblod/graph-rdfa-processor 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1106 @@
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
+ return baseURI;
401
+ };
402
+
403
+ queue.push({
404
+ current: node,
405
+ context: this.push(null, removeHash(node.baseURI))
406
+ });
407
+
408
+ while (queue.length > 0) {
409
+ var item = queue.shift();
410
+
411
+ if (item.parent) {
412
+ // Sequence Step 14: list triple generation
413
+ if (item.context.parent && item.context.parent.listMapping == item.listMapping) {
414
+ // Skip a child context with exactly the same mapping
415
+ continue;
416
+ } //console.log("Generating lists for "+item.subject+", tag "+item.parent.localName);
417
+
418
+
419
+ for (var predicate in item.listMapping) {
420
+ var list = item.listMapping[predicate];
421
+
422
+ if (list.length == 0) {
423
+ this.addTriple(item.parent, item.subject, predicate, {
424
+ type: RDFaProcessor.objectURI,
425
+ value: "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
426
+ });
427
+ continue;
428
+ }
429
+
430
+ var bnodes = [];
431
+
432
+ for (var i = 0; i < list.length; i++) {
433
+ bnodes.push(this.newBlankNode()); //this.newSubject(item.parent,bnodes[i]);
434
+ }
435
+
436
+ for (var i = 0; i < bnodes.length; i++) {
437
+ this.addTriple(item.parent, bnodes[i], "http://www.w3.org/1999/02/22-rdf-syntax-ns#first", list[i]);
438
+ this.addTriple(item.parent, bnodes[i], "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest", {
439
+ type: RDFaProcessor.objectURI,
440
+ value: i + 1 < bnodes.length ? bnodes[i + 1] : "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
441
+ });
442
+ }
443
+
444
+ this.addTriple(item.parent, item.subject, predicate, {
445
+ type: RDFaProcessor.objectURI,
446
+ value: bnodes[0]
447
+ });
448
+ }
449
+
450
+ continue;
451
+ }
452
+
453
+ var current = item.current;
454
+ var context = item.context; //console.log("Tag: "+current.localName+", listMapping="+JSON.stringify(context.listMapping));
455
+ // Sequence Step 1
456
+
457
+ var skip = false;
458
+ var newSubject = null;
459
+ var currentObjectResource = null;
460
+ var typedResource = null;
461
+ var prefixes = context.prefixes;
462
+ var prefixesCopied = false;
463
+ var incomplete = [];
464
+ var listMapping = context.listMapping;
465
+ var listMappingDifferent = context.parent ? false : true;
466
+ var language = context.language;
467
+ var vocabulary = context.vocabulary; // TODO: the "base" element may be used for HTML+RDFa 1.1
468
+
469
+ var base;
470
+
471
+ if (!current.baseURI) {
472
+ if (this.target.baseURI) {
473
+ base = this.target.baseURI;
474
+ } else {
475
+ throw new Error("node.baseURI was null as baseURI must be specified as an option");
476
+ }
477
+ } else if (current.baseURI === "about:blank") {
478
+ if (this.target.baseURI) {
479
+ base = this.target.baseURI;
480
+ } else {
481
+ 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");
482
+ }
483
+ } else {
484
+ base = this.parseURI(removeHash(current.baseURI));
485
+ }
486
+
487
+ current.item = null; // Sequence Step 2: set the default vocabulary
488
+
489
+ var vocabAtt = current.getAttributeNode("vocab");
490
+
491
+ if (vocabAtt) {
492
+ var value = RDFaProcessor.trim(vocabAtt.value);
493
+
494
+ if (value.length > 0) {
495
+ vocabulary = value;
496
+ var baseSubject = base.spec; //this.newSubject(current,baseSubject);
497
+
498
+ this.addTriple(current, baseSubject, "http://www.w3.org/ns/rdfa#usesVocabulary", {
499
+ type: RDFaProcessor.objectURI,
500
+ value: vocabulary
501
+ });
502
+ } else {
503
+ vocabulary = this.vocabulary;
504
+ }
505
+ } // Sequence Step 3: IRI mappings
506
+ // handle xmlns attributes
507
+
508
+
509
+ for (var i = 0; i < current.attributes.length; i++) {
510
+ var att = current.attributes[i]; //if (att.namespaceURI=="http://www.w3.org/2000/xmlns/") {
511
+
512
+ if (att.name.charAt(0) == "x" && att.name.indexOf("xmlns:") == 0) {
513
+ if (!prefixesCopied) {
514
+ prefixes = this.copyMappings(prefixes);
515
+ prefixesCopied = true;
516
+ }
517
+
518
+ var prefix = att.name.substring(6); // TODO: resolve relative?
519
+
520
+ var ref = RDFaProcessor.trim(att.value);
521
+ prefixes[prefix] = this.target.baseURI ? this.target.baseURI.resolve(ref) : ref;
522
+ }
523
+ } // Handle prefix mappings (@prefix)
524
+
525
+
526
+ var prefixAtt = current.getAttributeNode("prefix");
527
+
528
+ if (prefixAtt) {
529
+ if (!prefixesCopied) {
530
+ prefixes = this.copyMappings(prefixes);
531
+ prefixesCopied = true;
532
+ }
533
+
534
+ this.parsePrefixMappings(prefixAtt.value, prefixes);
535
+ } // Sequence Step 4: language
536
+
537
+
538
+ var xmlLangAtt = null;
539
+
540
+ for (var i = 0; !xmlLangAtt && i < this.langAttributes.length; i++) {
541
+ xmlLangAtt = current.getAttributeNodeNS(this.langAttributes[i].namespaceURI, this.langAttributes[i].localName);
542
+ }
543
+
544
+ if (xmlLangAtt) {
545
+ var value = RDFaProcessor.trim(xmlLangAtt.value);
546
+
547
+ if (value.length > 0) {
548
+ language = value;
549
+ } else {
550
+ language = null;
551
+ }
552
+ }
553
+
554
+ var relAtt = current.getAttributeNode("rel");
555
+ var revAtt = current.getAttributeNode("rev");
556
+ var typeofAtt = current.getAttributeNode("typeof");
557
+ var propertyAtt = current.getAttributeNode("property");
558
+ var datatypeAtt = current.getAttributeNode("datatype");
559
+ var datetimeAtt = this.inHTMLMode ? current.getAttributeNode("datetime") : null;
560
+ var contentAtt = current.getAttributeNode("content");
561
+ var aboutAtt = current.getAttributeNode("about");
562
+ var srcAtt = current.getAttributeNode("src");
563
+ var resourceAtt = current.getAttributeNode("resource");
564
+ var hrefAtt = current.getAttributeNode("href");
565
+ var inlistAtt = current.getAttributeNode("inlist");
566
+ var relAttPredicates = [];
567
+
568
+ if (relAtt) {
569
+ var values = this.tokenize(relAtt.value);
570
+
571
+ for (var i = 0; i < values.length; i++) {
572
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt != null);
573
+
574
+ if (predicate) {
575
+ relAttPredicates.push(predicate);
576
+ }
577
+ }
578
+ }
579
+
580
+ var revAttPredicates = [];
581
+
582
+ if (revAtt) {
583
+ var values = this.tokenize(revAtt.value);
584
+
585
+ for (var i = 0; i < values.length; i++) {
586
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base, this.inHTMLMode && propertyAtt != null);
587
+
588
+ if (predicate) {
589
+ revAttPredicates.push(predicate);
590
+ }
591
+ }
592
+ } // Section 3.1, bullet 7
593
+
594
+
595
+ if (this.inHTMLMode && (relAtt != null || revAtt != null) && propertyAtt != null) {
596
+ if (relAttPredicates.length == 0) {
597
+ relAtt = null;
598
+ }
599
+
600
+ if (revAttPredicates.length == 0) {
601
+ revAtt = null;
602
+ }
603
+ }
604
+
605
+ if (relAtt || revAtt) {
606
+ // Sequence Step 6: establish new subject and value
607
+ if (aboutAtt) {
608
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
609
+ }
610
+
611
+ if (typeofAtt) {
612
+ typedResource = newSubject;
613
+ }
614
+
615
+ if (!newSubject) {
616
+ if (current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
617
+ newSubject = removeHash(current.baseURI);
618
+ } else if (context.parentObject) {
619
+ // 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
620
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
621
+ }
622
+ }
623
+
624
+ if (resourceAtt) {
625
+ currentObjectResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
626
+ }
627
+
628
+ if (!currentObjectResource) {
629
+ if (hrefAtt) {
630
+ currentObjectResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
631
+ } else if (srcAtt) {
632
+ currentObjectResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
633
+ } else if (typeofAtt && !aboutAtt && !(this.inXHTMLMode && (current.localName == "head" || current.localName == "body"))) {
634
+ currentObjectResource = this.newBlankNode();
635
+ }
636
+ }
637
+
638
+ if (typeofAtt && !aboutAtt && this.inXHTMLMode && (current.localName == "head" || current.localName == "body")) {
639
+ typedResource = newSubject;
640
+ } else if (typeofAtt && !aboutAtt) {
641
+ typedResource = currentObjectResource;
642
+ }
643
+ } else if (propertyAtt && !contentAtt && !datatypeAtt) {
644
+ // Sequence Step 5.1: establish a new subject
645
+ if (aboutAtt) {
646
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
647
+
648
+ if (typeofAtt) {
649
+ typedResource = newSubject;
650
+ }
651
+ }
652
+
653
+ if (!newSubject && current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
654
+ newSubject = removeHash(current.baseURI);
655
+
656
+ if (typeofAtt) {
657
+ typedResource = newSubject;
658
+ }
659
+ } else if (!newSubject && context.parentObject) {
660
+ // 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
661
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
662
+ }
663
+
664
+ if (typeofAtt && !typedResource) {
665
+ if (resourceAtt) {
666
+ typedResource = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
667
+ }
668
+
669
+ if (!typedResource && hrefAtt) {
670
+ typedResource = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
671
+ }
672
+
673
+ if (!typedResource && srcAtt) {
674
+ typedResource = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
675
+ }
676
+
677
+ if (!typedResource && (this.inXHTMLMode || this.inHTMLMode) && (current.localName == "head" || current.localName == "body")) {
678
+ typedResource = newSubject;
679
+ }
680
+
681
+ if (!typedResource) {
682
+ typedResource = this.newBlankNode();
683
+ }
684
+
685
+ currentObjectResource = typedResource;
686
+ } //console.log(current.localName+", newSubject="+newSubject+", typedResource="+typedResource+", currentObjectResource="+currentObjectResource);
687
+
688
+ } else {
689
+ // Sequence Step 5.2: establish a new subject
690
+ if (aboutAtt) {
691
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value, prefixes, base);
692
+ }
693
+
694
+ if (!newSubject && resourceAtt) {
695
+ newSubject = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
696
+ }
697
+
698
+ if (!newSubject && hrefAtt) {
699
+ newSubject = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
700
+ }
701
+
702
+ if (!newSubject && srcAtt) {
703
+ newSubject = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
704
+ }
705
+
706
+ if (!newSubject) {
707
+ if (current.parentNode.nodeType == _node.default.DOCUMENT_NODE) {
708
+ newSubject = removeHash(current.baseURI);
709
+ } else if ((this.inXHTMLMode || this.inHTMLMode) && (current.localName == "head" || current.localName == "body")) {
710
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
711
+ } else if (typeofAtt) {
712
+ newSubject = this.newBlankNode();
713
+ } else if (context.parentObject) {
714
+ // 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
715
+ newSubject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
716
+
717
+ if (!propertyAtt) {
718
+ skip = true;
719
+ }
720
+ }
721
+ }
722
+
723
+ if (typeofAtt) {
724
+ typedResource = newSubject;
725
+ }
726
+ } //console.log(current.tagName+": newSubject="+newSubject+", currentObjectResource="+currentObjectResource+", typedResource="+typedResource+", skip="+skip);
727
+
728
+
729
+ var rdfaData = null;
730
+
731
+ if (newSubject) {
732
+ //this.newSubject(current,newSubject);
733
+ if (aboutAtt || resourceAtt || typedResource) {
734
+ var id = newSubject;
735
+
736
+ if (typeofAtt && !aboutAtt && !resourceAtt && currentObjectResource) {
737
+ id = currentObjectResource;
738
+ } //console.log("Setting data attribute for "+current.localName+" for subject "+id);
739
+
740
+
741
+ this.newSubjectOrigin(current, id);
742
+ }
743
+ } // Sequence Step 7: generate type triple
744
+
745
+
746
+ if (typedResource) {
747
+ var values = this.tokenize(typeofAtt.value);
748
+
749
+ for (var i = 0; i < values.length; i++) {
750
+ var object = this.parseTermOrCURIEOrAbsURI(values[i], vocabulary, context.terms, prefixes, base);
751
+
752
+ if (object) {
753
+ this.addTriple(current, typedResource, RDFaProcessor.typeURI, {
754
+ type: RDFaProcessor.objectURI,
755
+ value: object
756
+ });
757
+ }
758
+ }
759
+ } // Sequence Step 8: new list mappings if there is a new subject
760
+ //console.log("Step 8: newSubject="+newSubject+", context.parentObject="+context.parentObject);
761
+
762
+
763
+ if (newSubject && newSubject != context.parentObject) {
764
+ //console.log("Generating new list mapping for "+newSubject);
765
+ listMapping = {};
766
+ listMappingDifferent = true;
767
+ } // Sequence Step 9: generate object triple
768
+
769
+
770
+ if (currentObjectResource) {
771
+ if (relAtt && inlistAtt) {
772
+ for (var i = 0; i < relAttPredicates.length; i++) {
773
+ var list = listMapping[relAttPredicates[i]];
774
+
775
+ if (!list) {
776
+ list = [];
777
+ listMapping[relAttPredicates[i]] = list;
778
+ }
779
+
780
+ list.push({
781
+ type: RDFaProcessor.objectURI,
782
+ value: currentObjectResource
783
+ });
784
+ }
785
+ } else if (relAtt) {
786
+ for (var i = 0; i < relAttPredicates.length; i++) {
787
+ this.addTriple(current, newSubject, relAttPredicates[i], {
788
+ type: RDFaProcessor.objectURI,
789
+ value: currentObjectResource
790
+ });
791
+ }
792
+ }
793
+
794
+ if (revAtt) {
795
+ for (var i = 0; i < revAttPredicates.length; i++) {
796
+ this.addTriple(current, currentObjectResource, revAttPredicates[i], {
797
+ type: RDFaProcessor.objectURI,
798
+ value: newSubject
799
+ });
800
+ }
801
+ }
802
+ } else {
803
+ // Sequence Step 10: incomplete triples
804
+ if (newSubject && !currentObjectResource && (relAtt || revAtt)) {
805
+ currentObjectResource = this.newBlankNode(); //alert(current.tagName+": generated blank node, newSubject="+newSubject+" currentObjectResource="+currentObjectResource);
806
+ }
807
+
808
+ if (relAtt && inlistAtt) {
809
+ for (var i = 0; i < relAttPredicates.length; i++) {
810
+ var list = listMapping[relAttPredicates[i]];
811
+
812
+ if (!list) {
813
+ list = [];
814
+ listMapping[predicate] = list;
815
+ } //console.log("Adding incomplete list for "+predicate);
816
+
817
+
818
+ incomplete.push({
819
+ predicate: relAttPredicates[i],
820
+ list: list
821
+ });
822
+ }
823
+ } else if (relAtt) {
824
+ for (var i = 0; i < relAttPredicates.length; i++) {
825
+ incomplete.push({
826
+ predicate: relAttPredicates[i],
827
+ forward: true
828
+ });
829
+ }
830
+ }
831
+
832
+ if (revAtt) {
833
+ for (var i = 0; i < revAttPredicates.length; i++) {
834
+ incomplete.push({
835
+ predicate: revAttPredicates[i],
836
+ forward: false
837
+ });
838
+ }
839
+ }
840
+ } // Step 11: Current property values
841
+
842
+
843
+ if (propertyAtt) {
844
+ var datatype = null;
845
+ var content = null;
846
+
847
+ if (datatypeAtt) {
848
+ datatype = datatypeAtt.value == "" ? RDFaProcessor.PlainLiteralURI : this.parseTermOrCURIEOrAbsURI(datatypeAtt.value, vocabulary, context.terms, prefixes, base);
849
+
850
+ if (datetimeAtt && !contentAtt) {
851
+ content = datetimeAtt.value;
852
+ } else {
853
+ content = datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI ? null : contentAtt ? contentAtt.value : current.textContent;
854
+ }
855
+ } else if (contentAtt) {
856
+ datatype = RDFaProcessor.PlainLiteralURI;
857
+ content = contentAtt.value;
858
+ } else if (datetimeAtt) {
859
+ content = datetimeAtt.value;
860
+ datatype = RDFaProcessor.deriveDateTimeType(content);
861
+
862
+ if (!datatype) {
863
+ datatype = RDFaProcessor.PlainLiteralURI;
864
+ }
865
+ } else if (!relAtt && !revAtt) {
866
+ if (resourceAtt) {
867
+ content = this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value, prefixes, base);
868
+ }
869
+
870
+ if (!content && hrefAtt) {
871
+ content = this.resolveAndNormalize(base, encodeURI(hrefAtt.value));
872
+ } else if (!content && srcAtt) {
873
+ content = this.resolveAndNormalize(base, encodeURI(srcAtt.value));
874
+ }
875
+
876
+ if (content) {
877
+ datatype = RDFaProcessor.objectURI;
878
+ }
879
+ }
880
+
881
+ if (!datatype) {
882
+ if (typeofAtt && !aboutAtt) {
883
+ datatype = RDFaProcessor.objectURI;
884
+ content = typedResource;
885
+ } else {
886
+ content = current.textContent;
887
+
888
+ if (this.inHTMLMode && current.localName == "time") {
889
+ datatype = RDFaProcessor.deriveDateTimeType(content);
890
+ }
891
+
892
+ if (!datatype) {
893
+ datatype = RDFaProcessor.PlainLiteralURI;
894
+ }
895
+ }
896
+ }
897
+
898
+ var values = this.tokenize(propertyAtt.value);
899
+
900
+ for (var i = 0; i < values.length; i++) {
901
+ var predicate = this.parsePredicate(values[i], vocabulary, context.terms, prefixes, base);
902
+
903
+ if (predicate) {
904
+ if (inlistAtt) {
905
+ var list = listMapping[predicate];
906
+
907
+ if (!list) {
908
+ list = [];
909
+ listMapping[predicate] = list;
910
+ }
911
+
912
+ list.push(datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI ? {
913
+ type: datatype,
914
+ value: current.childNodes
915
+ } : {
916
+ type: datatype ? datatype : RDFaProcessor.PlainLiteralURI,
917
+ value: content,
918
+ language: language
919
+ });
920
+ } else {
921
+ if (datatype == RDFaProcessor.XMLLiteralURI || datatype == RDFaProcessor.HTMLLiteralURI) {
922
+ this.addTriple(current, newSubject, predicate, {
923
+ type: datatype,
924
+ value: current.childNodes
925
+ });
926
+ } else {
927
+ this.addTriple(current, newSubject, predicate, {
928
+ type: datatype ? datatype : RDFaProcessor.PlainLiteralURI,
929
+ value: content,
930
+ language: language
931
+ });
932
+ var specialPredicate = this.target.specialHtmlPredicates.find(function (sp) {
933
+ return sp.source === predicate;
934
+ });
935
+
936
+ if (specialPredicate) {
937
+ this.addTriple(current, newSubject, specialPredicate.target, {
938
+ type: RDFaProcessor.HTMLLiteralURI,
939
+ value: current.childNodes
940
+ });
941
+ } //console.log(newSubject+" "+predicate+"="+content);
942
+
943
+ }
944
+ }
945
+ }
946
+ }
947
+ } // Sequence Step 12: complete incomplete triples with new subject
948
+
949
+
950
+ if (newSubject && !skip) {
951
+ for (var i = 0; i < context.incomplete.length; i++) {
952
+ if (context.incomplete[i].list) {
953
+ //console.log("Adding subject "+newSubject+" to list for "+context.incomplete[i].predicate);
954
+ // TODO: it is unclear what to do here
955
+ context.incomplete[i].list.push({
956
+ type: RDFaProcessor.objectURI,
957
+ value: newSubject
958
+ });
959
+ } else if (context.incomplete[i].forward) {
960
+ //console.log(current.tagName+": completing forward triple "+context.incomplete[i].predicate+" with object="+newSubject);
961
+ this.addTriple(current, context.subject, context.incomplete[i].predicate, {
962
+ type: RDFaProcessor.objectURI,
963
+ value: newSubject
964
+ });
965
+ } else {
966
+ //console.log(current.tagName+": completing reverse triple with object="+context.subject);
967
+ this.addTriple(current, newSubject, context.incomplete[i].predicate, {
968
+ type: RDFaProcessor.objectURI,
969
+ value: context.subject
970
+ });
971
+ }
972
+ }
973
+ }
974
+
975
+ var childContext = null;
976
+ var listSubject = newSubject;
977
+
978
+ if (skip) {
979
+ // TODO: should subject be null?
980
+ 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.
981
+ // TODO: Verify: if the current baseURI has changed and the parentObject is the parent's base URI, then the baseURI should change
982
+
983
+ childContext.parentObject = removeHash(current.parentNode.baseURI) == context.parentObject ? removeHash(current.baseURI) : context.parentObject;
984
+ childContext.incomplete = context.incomplete;
985
+ childContext.language = language;
986
+ childContext.prefixes = prefixes;
987
+ childContext.vocabulary = vocabulary;
988
+ } else {
989
+ childContext = this.push(context, newSubject);
990
+ childContext.parentObject = currentObjectResource ? currentObjectResource : newSubject ? newSubject : context.subject;
991
+ childContext.prefixes = prefixes;
992
+ childContext.incomplete = incomplete;
993
+
994
+ if (currentObjectResource) {
995
+ //console.log("Generating new list mapping for "+currentObjectResource);
996
+ listSubject = currentObjectResource;
997
+ listMapping = {};
998
+ listMappingDifferent = true;
999
+ }
1000
+
1001
+ childContext.listMapping = listMapping;
1002
+ childContext.language = language;
1003
+ childContext.vocabulary = vocabulary;
1004
+ }
1005
+
1006
+ if (listMappingDifferent) {
1007
+ //console.log("Pushing list parent "+current.localName);
1008
+ queue.unshift({
1009
+ parent: current,
1010
+ context: context,
1011
+ subject: listSubject,
1012
+ listMapping: listMapping
1013
+ });
1014
+ }
1015
+
1016
+ for (var child = current.lastChild; child; child = child.previousSibling) {
1017
+ if (child.nodeType == _node.default.ELEMENT_NODE) {
1018
+ //console.log("Pushing child "+child.localName);
1019
+ queue.unshift({
1020
+ current: child,
1021
+ context: childContext
1022
+ });
1023
+ }
1024
+ }
1025
+ }
1026
+
1027
+ if (this.inHTMLMode) {
1028
+ this.copyProperties();
1029
+ }
1030
+
1031
+ for (var i = 0; i < this.finishedHandlers.length; i++) {
1032
+ this.finishedHandlers[i](node);
1033
+ }
1034
+ }
1035
+ }, {
1036
+ key: "copyProperties",
1037
+ value: function copyProperties() {}
1038
+ }, {
1039
+ key: "push",
1040
+ value: function push(parent, subject) {
1041
+ return {
1042
+ parent: parent,
1043
+ subject: subject ? subject : parent ? parent.subject : null,
1044
+ parentObject: null,
1045
+ incomplete: [],
1046
+ listMapping: parent ? parent.listMapping : {},
1047
+ language: parent ? parent.language : this.language,
1048
+ prefixes: parent ? parent.prefixes : this.target.graph.prefixes,
1049
+ terms: parent ? parent.terms : this.target.graph.terms,
1050
+ vocabulary: parent ? parent.vocabulary : this.vocabulary
1051
+ };
1052
+ }
1053
+ }]);
1054
+
1055
+ return RDFaProcessor;
1056
+ }(_uriResolver.default);
1057
+
1058
+ exports.default = RDFaProcessor;
1059
+ RDFaProcessor.XMLLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
1060
+ RDFaProcessor.HTMLLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML";
1061
+ RDFaProcessor.PlainLiteralURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral";
1062
+ RDFaProcessor.objectURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#object";
1063
+ RDFaProcessor.typeURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
1064
+ 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]";
1065
+ 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_]";
1066
+ RDFaProcessor.NCNAME = new RegExp("^" + RDFaProcessor.nameStartChar + RDFaProcessor.nameChar + "*$");
1067
+
1068
+ RDFaProcessor.trim = function (str) {
1069
+ return str.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
1070
+ };
1071
+
1072
+ RDFaProcessor.dateTimeTypes = [{
1073
+ pattern: /-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,
1074
+ type: "http://www.w3.org/2001/XMLSchema#duration"
1075
+ }, {
1076
+ 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])?/,
1077
+ type: "http://www.w3.org/2001/XMLSchema#dateTime"
1078
+ }, {
1079
+ 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])?/,
1080
+ type: "http://www.w3.org/2001/XMLSchema#date"
1081
+ }, {
1082
+ 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])?/,
1083
+ type: "http://www.w3.org/2001/XMLSchema#time"
1084
+ }, {
1085
+ 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]/,
1086
+ type: "http://www.w3.org/2001/XMLSchema#gYearMonth"
1087
+ }, {
1088
+ pattern: /-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,
1089
+ type: "http://www.w3.org/2001/XMLSchema#gYear"
1090
+ }];
1091
+
1092
+ RDFaProcessor.deriveDateTimeType = function (value) {
1093
+ for (var i = 0; i < RDFaProcessor.dateTimeTypes.length; i++) {
1094
+ //console.log("Checking "+value+" against "+RDFaProcessor.dateTimeTypes[i].type);
1095
+ var matched = RDFaProcessor.dateTimeTypes[i].pattern.exec(value);
1096
+
1097
+ if (matched && matched[0].length == value.length) {
1098
+ //console.log("Matched!");
1099
+ return RDFaProcessor.dateTimeTypes[i].type;
1100
+ }
1101
+ }
1102
+
1103
+ return null;
1104
+ };
1105
+
1106
+ module.exports = exports.default;