xml-toolkit 1.0.8 → 1.0.9
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/lib/NamespacePrefixesMap.js +18 -20
- package/lib/XMLMarshaller.js +1 -4
- package/lib/XMLSchemata.js +1 -1
- package/package.json +1 -1
- package/test/test.js +8 -4
|
@@ -2,40 +2,38 @@ const assert = require ('assert')
|
|
|
2
2
|
|
|
3
3
|
const NamespacePrefixesMap = class extends Map {
|
|
4
4
|
|
|
5
|
-
constructor (schemata,
|
|
5
|
+
constructor (schemata, node) {
|
|
6
6
|
|
|
7
|
-
assert.strictEqual (typeof o, 'object')
|
|
8
|
-
|
|
9
7
|
super ()
|
|
10
8
|
|
|
11
9
|
this.schemata = schemata
|
|
12
10
|
|
|
13
|
-
this.
|
|
14
|
-
|
|
11
|
+
this.checkNode (node)
|
|
12
|
+
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
checkNode ({targetNamespace, attributes, children}) {
|
|
16
|
+
|
|
17
|
+
this.checkURI (targetNamespace)
|
|
18
|
+
|
|
19
|
+
for (const a of Object.values (attributes))
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
if (Array.isArray (a) && a.length === 2)
|
|
22
|
+
|
|
23
|
+
this.checkURI (a [1])
|
|
24
|
+
|
|
25
|
+
for (const i of children) this.checkNode (i)
|
|
22
26
|
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
checkURI (uri) {
|
|
26
30
|
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
const uri = a [1]
|
|
32
|
-
|
|
33
|
-
if (!this.schemata.has (uri)) return false
|
|
31
|
+
if (this.has (uri)) return
|
|
32
|
+
|
|
33
|
+
if (!this.schemata.has (uri)) return
|
|
34
34
|
|
|
35
|
-
if (this.has (uri)) return true
|
|
36
|
-
|
|
37
35
|
this.set (uri, 'ns' + this.size)
|
|
38
|
-
|
|
36
|
+
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
QName (localName, namespaceURI) {
|
package/lib/XMLMarshaller.js
CHANGED
|
@@ -109,10 +109,6 @@ const XMLMarshaller = class {
|
|
|
109
109
|
|
|
110
110
|
switch (localName) {
|
|
111
111
|
|
|
112
|
-
case 'simpleType':
|
|
113
|
-
|
|
114
|
-
return this.appendScalar (node, data)
|
|
115
|
-
|
|
116
112
|
case 'attribute':
|
|
117
113
|
|
|
118
114
|
if (!(name in data)) return
|
|
@@ -135,6 +131,7 @@ const XMLMarshaller = class {
|
|
|
135
131
|
case 'sequence':
|
|
136
132
|
case 'choice':
|
|
137
133
|
case 'group':
|
|
134
|
+
case 'simpleType':
|
|
138
135
|
|
|
139
136
|
return
|
|
140
137
|
|
package/lib/XMLSchemata.js
CHANGED
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -114,13 +114,13 @@ async function test_004_schemata (fn) {
|
|
|
114
114
|
const o = s.get (localName)
|
|
115
115
|
|
|
116
116
|
const nspm = xs.getNamespacePrefixesMap (o)
|
|
117
|
-
*/
|
|
118
117
|
|
|
119
118
|
console.log (xs.stringify ({
|
|
120
119
|
"ExportDebtRequestsRequest": {Id: 1}
|
|
121
120
|
}))
|
|
121
|
+
*/
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
console.log (xs.stringify ({
|
|
124
124
|
"ExportDebtRequestsResponse": {
|
|
125
125
|
"request-data": {
|
|
126
126
|
"request-id": "bac4c940-6ad3-11eb-9439-0242ac130002",
|
|
@@ -216,6 +216,10 @@ async function test_004_schemata (fn) {
|
|
|
216
216
|
console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ActionType').restriction)
|
|
217
217
|
*/
|
|
218
218
|
|
|
219
|
+
console.log (xs.stringify ({
|
|
220
|
+
"ExportDebtRequestsRequest": {Id: 1}
|
|
221
|
+
}))
|
|
222
|
+
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
async function test_005_schemata (fn) {
|
|
@@ -325,8 +329,8 @@ async function main () {
|
|
|
325
329
|
// await test_003_emitter_sync ('not-sa01.xml')
|
|
326
330
|
// await test_003_emitter_sync ('ent.xml')
|
|
327
331
|
// await test_003_emitter_sync ('soap.xml')
|
|
328
|
-
|
|
329
|
-
await test_005_schemata ()
|
|
332
|
+
await test_004_schemata ()
|
|
333
|
+
// await test_005_schemata ()
|
|
330
334
|
// await test_006_schemata ()
|
|
331
335
|
|
|
332
336
|
}
|