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
package/src/named-node.ts
CHANGED
|
File without changes
|
package/src/namespace.ts
CHANGED
|
File without changes
|
package/src/node-internal.ts
CHANGED
|
File without changes
|
package/src/node.ts
CHANGED
|
File without changes
|
package/src/parse.ts
CHANGED
|
File without changes
|
package/src/patch-parser.js
CHANGED
|
File without changes
|
package/src/query-to-sparql.js
CHANGED
|
File without changes
|
package/src/query.js
CHANGED
|
File without changes
|
package/src/rdfaparser.js
CHANGED
|
File without changes
|
package/src/rdfxmlparser.js
CHANGED
|
@@ -57,23 +57,31 @@
|
|
|
57
57
|
*/
|
|
58
58
|
import * as uriUtil from './uri'
|
|
59
59
|
|
|
60
|
-
/*
|
|
61
|
-
* @constructor
|
|
62
|
-
* @param {RDFStore} store An RDFStore object
|
|
63
|
-
*/
|
|
64
60
|
|
|
65
|
-
export default
|
|
66
|
-
|
|
61
|
+
export default class RDFParser {
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* @constructor
|
|
65
|
+
* @param {RDFStore} store An RDFStore object
|
|
66
|
+
*/
|
|
67
|
+
constructor(store) {
|
|
68
|
+
/** Our triple store reference @private */
|
|
69
|
+
|
|
70
|
+
this.store = store /** Our identified blank nodes @private */
|
|
71
|
+
this.bnodes = {} /** A context for context-aware stores @private */
|
|
72
|
+
this.why = null /** Reification flag */
|
|
73
|
+
this.reify = false
|
|
74
|
+
}
|
|
67
75
|
|
|
68
76
|
/** Standard namespaces that we know how to handle @final
|
|
69
77
|
* @member RDFParser
|
|
70
78
|
*/
|
|
71
|
-
|
|
79
|
+
static ns = {'RDF': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'RDFS': 'http://www.w3.org/2000/01/rdf-schema#'}
|
|
72
80
|
|
|
73
81
|
/** DOM Level 2 node type magic numbers @final
|
|
74
82
|
* @member RDFParser
|
|
75
83
|
*/
|
|
76
|
-
|
|
84
|
+
static nodeType = {'ELEMENT': 1, 'ATTRIBUTE': 2, 'TEXT': 3,
|
|
77
85
|
'CDATA_SECTION': 4, 'ENTITY_REFERENCE': 5,
|
|
78
86
|
'ENTITY': 6, 'PROCESSING_INSTRUCTION': 7,
|
|
79
87
|
'COMMENT': 8, 'DOCUMENT': 9, 'DOCUMENT_TYPE': 10,
|
|
@@ -87,7 +95,7 @@ export default function RDFParser(store) {
|
|
|
87
95
|
* @private
|
|
88
96
|
*/
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
frameFactory(parser, parent, element) {
|
|
91
99
|
return {'NODE': 1, 'ARC': 2, 'parent': parent, 'parser': parser, 'store': parser.store, 'element': element,
|
|
92
100
|
'lastChild': 0, 'base': null, 'lang': null, 'node': null, 'nodeType': null, 'listIndex': 1, 'rdfid': null, 'datatype': null, 'collection': false, /** Terminate the frame and notify the store that we're done */
|
|
93
101
|
'terminateFrame': function () {
|
|
@@ -167,7 +175,7 @@ export default function RDFParser(store) {
|
|
|
167
175
|
}
|
|
168
176
|
|
|
169
177
|
// from the OpenLayers source .. needed to get around IE problems.
|
|
170
|
-
|
|
178
|
+
getAttributeNodeNS(node, uri, name) {
|
|
171
179
|
var attributeNode = null
|
|
172
180
|
if (node.getAttributeNodeNS) {
|
|
173
181
|
attributeNode = node.getAttributeNodeNS(uri, name)
|
|
@@ -188,13 +196,6 @@ export default function RDFParser(store) {
|
|
|
188
196
|
return attributeNode
|
|
189
197
|
}
|
|
190
198
|
|
|
191
|
-
/** Our triple store reference @private */
|
|
192
|
-
|
|
193
|
-
this.store = store /** Our identified blank nodes @private */
|
|
194
|
-
this.bnodes = {} /** A context for context-aware stores @private */
|
|
195
|
-
this.why = null /** Reification flag */
|
|
196
|
-
this.reify = false
|
|
197
|
-
|
|
198
199
|
/**
|
|
199
200
|
* Build our initial scope frame and parse the DOM into triples
|
|
200
201
|
* @param {DOMTree} document The DOM to parse
|
|
@@ -202,7 +203,7 @@ export default function RDFParser(store) {
|
|
|
202
203
|
* @param {Object} why The context to which this resource belongs
|
|
203
204
|
*/
|
|
204
205
|
|
|
205
|
-
|
|
206
|
+
parse(document, base, why) {
|
|
206
207
|
var children = document.childNodes // clean up for the next run
|
|
207
208
|
this.cleanParser() // figure out the root element
|
|
208
209
|
var root
|
|
@@ -228,7 +229,7 @@ export default function RDFParser(store) {
|
|
|
228
229
|
return true
|
|
229
230
|
}
|
|
230
231
|
|
|
231
|
-
|
|
232
|
+
parseDOM(frame) {
|
|
232
233
|
// a DOM utility function used in parsing
|
|
233
234
|
var rdfid
|
|
234
235
|
var elementURI = function (el) {
|
|
@@ -408,7 +409,7 @@ export default function RDFParser(store) {
|
|
|
408
409
|
* Cleans out state from a previous parse run
|
|
409
410
|
* @private
|
|
410
411
|
*/
|
|
411
|
-
|
|
412
|
+
cleanParser() {
|
|
412
413
|
this.bnodes = {}
|
|
413
414
|
this.why = null
|
|
414
415
|
}
|
|
@@ -417,7 +418,7 @@ export default function RDFParser(store) {
|
|
|
417
418
|
* Builds scope frame
|
|
418
419
|
* @private
|
|
419
420
|
*/
|
|
420
|
-
|
|
421
|
+
buildFrame(parent, element) {
|
|
421
422
|
var frame = this.frameFactory(this, parent, element)
|
|
422
423
|
if (parent) {
|
|
423
424
|
frame.base = parent.base
|
package/src/serialize.ts
CHANGED
|
@@ -30,7 +30,7 @@ export default function serialize (
|
|
|
30
30
|
* Defaults to Turtle.
|
|
31
31
|
*/
|
|
32
32
|
contentType?: string | ContentType,
|
|
33
|
-
callback?: (err: Error | undefined | null, result?: string
|
|
33
|
+
callback?: (err: Error | undefined | null, result?: string) => any,
|
|
34
34
|
options?: {
|
|
35
35
|
/**
|
|
36
36
|
* A string of letters, each of which set an options
|
|
@@ -42,7 +42,7 @@ export default function serialize (
|
|
|
42
42
|
base = base || target.value
|
|
43
43
|
const opts = options || {}
|
|
44
44
|
contentType = contentType || TurtleContentType // text/n3 if complex?
|
|
45
|
-
var documentString: string |
|
|
45
|
+
var documentString: string | undefined = undefined
|
|
46
46
|
try {
|
|
47
47
|
var sz = Serializer(kb)
|
|
48
48
|
if ((opts as any).flags) sz.setFlags((opts as any).flags)
|
|
@@ -92,7 +92,7 @@ export default function serialize (
|
|
|
92
92
|
throw err // Don't hide problems from caller in sync mode
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function executeCallback (err: Error | null | undefined, result: string |
|
|
95
|
+
function executeCallback (err: Error | null | undefined, result: string | undefined): string | undefined {
|
|
96
96
|
if (callback) {
|
|
97
97
|
callback(err, result)
|
|
98
98
|
return
|
package/src/serializer.js
CHANGED
|
@@ -13,8 +13,13 @@ import CanonicalDataFactory from './factories/canonical-data-factory'
|
|
|
13
13
|
import { createXSD } from './xsd'
|
|
14
14
|
import solidNs from 'solid-namespace'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
export default function createSerializer(store) {
|
|
18
|
+
return new Serializer(store);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class Serializer {
|
|
22
|
+
constructor(store) {
|
|
18
23
|
this.flags = ''
|
|
19
24
|
this.base = null
|
|
20
25
|
|
|
@@ -41,11 +46,17 @@ export default (function () {
|
|
|
41
46
|
this.xsd = createXSD(this.rdfFactory)
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
setBase(base) {
|
|
50
|
+
this.base = base;
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
setFlags(flags) {
|
|
55
|
+
this.flags = flags || '';
|
|
56
|
+
return this
|
|
57
|
+
}
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
toStr(x) {
|
|
49
60
|
var s = x.toNT()
|
|
50
61
|
if (x.termType === 'Graph') {
|
|
51
62
|
this.formulas[s] = x // remember as reverse does not work
|
|
@@ -53,7 +64,7 @@ export default (function () {
|
|
|
53
64
|
return s
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
fromStr(s) {
|
|
57
68
|
if (s[0] === '{') {
|
|
58
69
|
var x = this.formulas[s]
|
|
59
70
|
if (!x) console.log('No formula object for ' + s)
|
|
@@ -61,12 +72,13 @@ export default (function () {
|
|
|
61
72
|
}
|
|
62
73
|
return this.store.fromNT(s)
|
|
63
74
|
}
|
|
75
|
+
|
|
64
76
|
/* Accumulate Namespaces
|
|
65
77
|
**
|
|
66
78
|
** These are only hints. If two overlap, only one gets used
|
|
67
79
|
** There is therefore no guarantee in general.
|
|
68
80
|
*/
|
|
69
|
-
|
|
81
|
+
suggestPrefix(prefix, uri) {
|
|
70
82
|
if (prefix.slice(0, 7) === 'default') return // Try to weed these out
|
|
71
83
|
if (prefix.slice(0, 2) === 'ns') return // From others inferior algos
|
|
72
84
|
if (!prefix || !uri) return // empty strings not suitable
|
|
@@ -76,34 +88,34 @@ export default (function () {
|
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
// Takes a namespace -> prefix map
|
|
79
|
-
|
|
91
|
+
suggestNamespaces(namespaces) {
|
|
80
92
|
for (var px in namespaces) {
|
|
81
93
|
this.suggestPrefix(px, namespaces[px])
|
|
82
94
|
}
|
|
83
95
|
return this
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
|
|
98
|
+
checkIntegrity() {
|
|
87
99
|
var p, ns
|
|
88
100
|
for (p in this.namespaces) {
|
|
89
101
|
if (this.prefixes[this.namespaces[p]] !== p) {
|
|
90
102
|
throw new Error('Serializer integity error 1: ' + p + ', ' +
|
|
91
|
-
|
|
103
|
+
this.namespaces[p] + ', ' + this.prefixes[this.namespaces[p]] + '!')
|
|
92
104
|
}
|
|
93
105
|
}
|
|
94
106
|
for (ns in this.prefixes) {
|
|
95
107
|
if (this.namespaces[this.prefixes[ns]] !== ns) {
|
|
96
108
|
throw new Error('Serializer integity error 2: ' + ns + ', ' +
|
|
97
|
-
|
|
109
|
+
this.prefixs[ns] + ', ' + this.namespaces[this.prefixes[ns]] + '!')
|
|
98
110
|
}
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
// Make up an unused prefix for a random namespace
|
|
103
|
-
|
|
115
|
+
makeUpPrefix(uri) {
|
|
104
116
|
var p = uri
|
|
105
117
|
function canUseMethod (pp) {
|
|
106
|
-
if (!
|
|
118
|
+
if (!this.validPrefix.test(pp)) return false // bad format
|
|
107
119
|
if (pp === 'ns') return false // boring
|
|
108
120
|
if (pp in this.namespaces) return false // already used
|
|
109
121
|
this.prefixes[uri] = pp
|
|
@@ -131,13 +143,13 @@ export default (function () {
|
|
|
131
143
|
if (canUse(p.slice(0, 4))) return p.slice(0, 4)
|
|
132
144
|
if (canUse(p.slice(0, 1))) return p.slice(0, 1)
|
|
133
145
|
if (canUse(p.slice(0, 5))) return p.slice(0, 5)
|
|
134
|
-
if (!
|
|
146
|
+
if (!this.validPrefix.test(p)) {
|
|
135
147
|
p = 'n' // Otherwise the loop below may never termimnate
|
|
136
148
|
}
|
|
137
149
|
for (var j = 0; ; j++) if (canUse(p.slice(0, 3) + j)) return p.slice(0, 3) + j
|
|
138
150
|
}
|
|
139
151
|
|
|
140
|
-
|
|
152
|
+
rootSubjects(sts) {
|
|
141
153
|
var incoming = {}
|
|
142
154
|
var subjects = {}
|
|
143
155
|
var allBnodes = {}
|
|
@@ -194,15 +206,15 @@ export default (function () {
|
|
|
194
206
|
|
|
195
207
|
// //////////////////////////////////////////////////////
|
|
196
208
|
|
|
197
|
-
|
|
209
|
+
toN3(f) {
|
|
198
210
|
return this.statementsToN3(f.statements)
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
(
|
|
213
|
+
_notQNameChars = '\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~'
|
|
214
|
+
_notNameChars =
|
|
215
|
+
(this._notQNameChars + ':')
|
|
204
216
|
|
|
205
|
-
|
|
217
|
+
explicitURI(uri) {
|
|
206
218
|
if (this.flags.indexOf('r') < 0 && this.base) {
|
|
207
219
|
uri = Uri.refTo(this.base, uri)
|
|
208
220
|
} else if (this.flags.indexOf('u') >= 0) { // Unicode encoding NTriples style
|
|
@@ -213,7 +225,7 @@ export default (function () {
|
|
|
213
225
|
return '<' + uri + '>'
|
|
214
226
|
}
|
|
215
227
|
|
|
216
|
-
|
|
228
|
+
statementsToNTriples(sts) {
|
|
217
229
|
var sorted = sts.slice()
|
|
218
230
|
sorted.sort()
|
|
219
231
|
var str = ''
|
|
@@ -250,7 +262,7 @@ export default (function () {
|
|
|
250
262
|
return str
|
|
251
263
|
}
|
|
252
264
|
|
|
253
|
-
|
|
265
|
+
statementsToN3(sts) {
|
|
254
266
|
var indent = 4
|
|
255
267
|
var width = 80
|
|
256
268
|
var kb = this.store
|
|
@@ -400,9 +412,10 @@ export default (function () {
|
|
|
400
412
|
results = results.concat([objects])
|
|
401
413
|
return results
|
|
402
414
|
}
|
|
415
|
+
|
|
403
416
|
var propertyTree = propertyTreeMethod.bind(this)
|
|
404
417
|
|
|
405
|
-
function objectTreeMethod
|
|
418
|
+
function objectTreeMethod(obj, stats, force) {
|
|
406
419
|
if (obj.termType === 'BlankNode' &&
|
|
407
420
|
(force || stats.rootsHash[obj.toNT()] === undefined)) {// if not a root
|
|
408
421
|
if (stats.subjects[this.toStr(obj)]) {
|
|
@@ -413,9 +426,10 @@ export default (function () {
|
|
|
413
426
|
}
|
|
414
427
|
return termToN3(obj, stats)
|
|
415
428
|
}
|
|
429
|
+
|
|
416
430
|
var objectTree = objectTreeMethod.bind(this)
|
|
417
431
|
|
|
418
|
-
function termToN3Method
|
|
432
|
+
function termToN3Method(expr, stats) { //
|
|
419
433
|
var i, res
|
|
420
434
|
switch (expr.termType) {
|
|
421
435
|
case 'Graph':
|
|
@@ -435,7 +449,7 @@ export default (function () {
|
|
|
435
449
|
return this.atomicTermToN3(expr)
|
|
436
450
|
}
|
|
437
451
|
}
|
|
438
|
-
|
|
452
|
+
Serializer.prototype.termToN3 = termToN3
|
|
439
453
|
var termToN3 = termToN3Method.bind(this)
|
|
440
454
|
|
|
441
455
|
function prefixDirectivesMethod () {
|
|
@@ -459,7 +473,7 @@ export default (function () {
|
|
|
459
473
|
// //////////////////////////////////////////// Atomic Terms
|
|
460
474
|
|
|
461
475
|
// Deal with term level things and nesting with no bnode structure
|
|
462
|
-
|
|
476
|
+
atomicTermToN3 (expr, stats) {
|
|
463
477
|
switch (expr.termType) {
|
|
464
478
|
case 'BlankNode':
|
|
465
479
|
case 'Variable':
|
|
@@ -508,11 +522,11 @@ export default (function () {
|
|
|
508
522
|
|
|
509
523
|
// stringToN3: String escaping for N3
|
|
510
524
|
|
|
511
|
-
|
|
525
|
+
validPrefix = new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)
|
|
512
526
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
527
|
+
forbidden1 = new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)
|
|
528
|
+
forbidden3 = new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)
|
|
529
|
+
stringToN3(str, flags) {
|
|
516
530
|
if (!flags) flags = 'e'
|
|
517
531
|
var res = ''
|
|
518
532
|
var i, j, k
|
|
@@ -523,10 +537,10 @@ export default (function () {
|
|
|
523
537
|
flags.indexOf('n') < 0 && // Force single line
|
|
524
538
|
(str.indexOf('\n') > 0 || str.indexOf('"') > 0)) {
|
|
525
539
|
delim = '"""'
|
|
526
|
-
forbidden =
|
|
540
|
+
forbidden = this.forbidden3
|
|
527
541
|
} else {
|
|
528
542
|
delim = '"'
|
|
529
|
-
forbidden =
|
|
543
|
+
forbidden = this.forbidden1
|
|
530
544
|
}
|
|
531
545
|
for (i = 0; i < str.length;) {
|
|
532
546
|
forbidden.lastIndex = 0
|
|
@@ -556,7 +570,7 @@ export default (function () {
|
|
|
556
570
|
}
|
|
557
571
|
// A single symbol, either in <> or namespace notation
|
|
558
572
|
|
|
559
|
-
|
|
573
|
+
symbolToN3 (x) { // c.f. symbolString() in notation3.py
|
|
560
574
|
var uri = x.uri
|
|
561
575
|
var j = uri.indexOf('#')
|
|
562
576
|
if (j < 0 && this.flags.indexOf('/') < 0) {
|
|
@@ -567,7 +581,7 @@ export default (function () {
|
|
|
567
581
|
(uri.indexOf('http') === 0 || uri.indexOf('ws') === 0 || uri.indexOf('file') === 0)) {
|
|
568
582
|
var canSplit = true
|
|
569
583
|
for (var k = j + 1; k < uri.length; k++) {
|
|
570
|
-
if (
|
|
584
|
+
if (this._notNameChars.indexOf(uri[k]) >= 0) {
|
|
571
585
|
canSplit = false
|
|
572
586
|
break
|
|
573
587
|
}
|
|
@@ -604,33 +618,12 @@ export default (function () {
|
|
|
604
618
|
}
|
|
605
619
|
return this.explicitURI(uri)
|
|
606
620
|
}
|
|
607
|
-
// String escaping utilities
|
|
608
|
-
|
|
609
|
-
function hexify (str) { // also used in parser
|
|
610
|
-
return encodeURI(str)
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
function backslashUify (str) {
|
|
614
|
-
var res = ''
|
|
615
|
-
var k
|
|
616
|
-
for (var i = 0; i < str.length; i++) {
|
|
617
|
-
k = str.charCodeAt(i)
|
|
618
|
-
if (k > 65535) {
|
|
619
|
-
res += '\\U' + ('00000000' + k.toString(16)).slice(-8) // convert to upper?
|
|
620
|
-
} else if (k > 126) {
|
|
621
|
-
res += '\\u' + ('0000' + k.toString(16)).slice(-4)
|
|
622
|
-
} else {
|
|
623
|
-
res += str[i]
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
return res
|
|
627
|
-
}
|
|
628
621
|
|
|
629
622
|
// /////////////////////////// Quad store serialization
|
|
630
623
|
|
|
631
624
|
// @para. write - a function taking a single string to be output
|
|
632
625
|
//
|
|
633
|
-
|
|
626
|
+
writeStore(write) {
|
|
634
627
|
var kb = this.store
|
|
635
628
|
var fetcher = kb.fetcher
|
|
636
629
|
var session = fetcher && fetcher.appNode
|
|
@@ -671,7 +664,7 @@ export default (function () {
|
|
|
671
664
|
|
|
672
665
|
// ////////////////////////////////////////////// XML serialization
|
|
673
666
|
|
|
674
|
-
|
|
667
|
+
statementsToXML(sts) {
|
|
675
668
|
var indent = 4
|
|
676
669
|
var width = 80
|
|
677
670
|
|
|
@@ -935,7 +928,7 @@ export default (function () {
|
|
|
935
928
|
if (j < 0) throw new Error('Cannot make qname out of <' + uri + '>')
|
|
936
929
|
|
|
937
930
|
for (var k = j + 1; k < uri.length; k++) {
|
|
938
|
-
if (
|
|
931
|
+
if (this._notNameChars.indexOf(uri[k]) >= 0) {
|
|
939
932
|
throw new Error('Invalid character "' + uri[k] + '" cannot be in XML qname for URI: ' + uri)
|
|
940
933
|
}
|
|
941
934
|
}
|
|
@@ -970,7 +963,26 @@ export default (function () {
|
|
|
970
963
|
var tree2 = [str, tree, '</rdf:RDF>'] // @@ namespace declrations
|
|
971
964
|
return XMLtreeToString(tree2, -1)
|
|
972
965
|
} // End @@ body
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// String escaping utilities
|
|
969
|
+
|
|
970
|
+
function hexify (str) { // also used in parser
|
|
971
|
+
return encodeURI(str)
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function backslashUify (str) {
|
|
975
|
+
var res = ''
|
|
976
|
+
var k
|
|
977
|
+
for (var i = 0; i < str.length; i++) {
|
|
978
|
+
k = str.charCodeAt(i)
|
|
979
|
+
if (k > 65535) {
|
|
980
|
+
res += '\\U' + ('00000000' + k.toString(16)).slice(-8) // convert to upper?
|
|
981
|
+
} else if (k > 126) {
|
|
982
|
+
res += '\\u' + ('0000' + k.toString(16)).slice(-4)
|
|
983
|
+
} else {
|
|
984
|
+
res += str[i]
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return res
|
|
988
|
+
}
|
package/src/sparql-to-query.js
CHANGED
|
File without changes
|
package/src/statement.ts
CHANGED
|
File without changes
|
package/src/store.ts
CHANGED
|
File without changes
|
package/src/tf-types.ts
CHANGED
|
File without changes
|
package/src/types.ts
CHANGED
|
File without changes
|
package/src/update-manager.ts
CHANGED
|
File without changes
|
package/src/updates-via.js
CHANGED
|
File without changes
|
package/src/uri.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/utils/termValue.ts
CHANGED
|
File without changes
|
package/src/utils/terms.ts
CHANGED
|
File without changes
|
package/src/utils-js.js
CHANGED
|
File without changes
|
package/src/utils.ts
CHANGED
|
File without changes
|
package/src/variable.ts
CHANGED
|
File without changes
|
package/src/xsd-internal.js
CHANGED
|
File without changes
|
package/src/xsd.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import CanonicalDataFactory from
|
|
1
|
+
import CanonicalDataFactory from "./factories/canonical-data-factory";
|
|
2
2
|
|
|
3
3
|
export function createXSD(localFactory = CanonicalDataFactory) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
return {
|
|
5
|
+
boolean: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),
|
|
6
|
+
dateTime: localFactory.namedNode(
|
|
7
|
+
"http://www.w3.org/2001/XMLSchema#dateTime"
|
|
8
|
+
),
|
|
9
|
+
decimal: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#decimal"),
|
|
10
|
+
double: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#double"),
|
|
11
|
+
integer: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#integer"),
|
|
12
|
+
langString: localFactory.namedNode(
|
|
13
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
|
|
14
|
+
),
|
|
15
|
+
string: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#string"),
|
|
16
|
+
};
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
const defaultXSD = createXSD(CanonicalDataFactory)
|
|
19
|
+
const defaultXSD = createXSD(CanonicalDataFactory);
|
|
18
20
|
|
|
19
|
-
export default defaultXSD
|
|
21
|
+
export default defaultXSD;
|