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