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.
@@ -2,40 +2,38 @@ const assert = require ('assert')
2
2
 
3
3
  const NamespacePrefixesMap = class extends Map {
4
4
 
5
- constructor (schemata, o) {
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.add (o)
14
-
11
+ this.checkNode (node)
12
+
15
13
  }
16
14
 
17
- add (o) {
18
-
19
- if (this.isAddedAsNamespaceReference (o)) return
15
+ checkNode ({targetNamespace, attributes, children}) {
16
+
17
+ this.checkURI (targetNamespace)
18
+
19
+ for (const a of Object.values (attributes))
20
20
 
21
- for (let v of Object.values (o)) if (typeof v === 'object') this.add (v)
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
- isAddedAsNamespaceReference (a) {
29
+ checkURI (uri) {
26
30
 
27
- if (!Array.isArray (a)) return false
28
-
29
- if (a.length !== 2) return false
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) {
@@ -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
 
@@ -114,7 +114,7 @@ const XMLSchemata = class extends Map {
114
114
 
115
115
  }
116
116
 
117
- const {targetNamespace} = options, mapper = n => n.detach ({nsMap: true})
117
+ const {targetNamespace} = options, mapper = n => n.detach ()
118
118
 
119
119
  for await (const node of
120
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-toolkit",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Collection of classes for dealing with XML",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
- if (0) console.log (xs.stringify ({
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
- // await test_004_schemata ()
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
  }