xml-toolkit 1.0.47 → 1.0.48

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.
Files changed (2) hide show
  1. package/lib/XMLSchema.js +44 -37
  2. package/package.json +1 -1
package/lib/XMLSchema.js CHANGED
@@ -3,42 +3,6 @@ const TYPES = Symbol ('_types')
3
3
  const FORM_U = 'unqualified'
4
4
  const FORM_Q = 'qualified'
5
5
 
6
- const adjustNode = node => {
7
-
8
- node.children = node.children
9
- .filter (i => i.localName !== 'annotation')
10
- .map (node => adjustNode (node))
11
-
12
- const {attributes, namespacesMap} = node, splitNs = name => {
13
-
14
- if (!attributes.has (name)) return
15
-
16
- const value = attributes.get (name), pos = value.indexOf (':')
17
-
18
- attributes.set (name, [value.substring (pos + 1), namespacesMap.get (value.substring (0, pos))])
19
-
20
- }
21
-
22
- switch (node.localName) {
23
-
24
- case 'attribute':
25
- case 'element':
26
- case 'group':
27
- splitNs ('ref')
28
- splitNs ('type')
29
- break
30
-
31
- case 'extension':
32
- case 'restriction':
33
- splitNs ('base')
34
- break
35
-
36
- }
37
-
38
- return node
39
-
40
- }
41
-
42
6
  const XMLSchema = class extends Map {
43
7
 
44
8
  static namespaceURI = 'http://www.w3.org/2001/XMLSchema'
@@ -56,6 +20,49 @@ const XMLSchema = class extends Map {
56
20
  this.setSource (node)
57
21
 
58
22
  }
23
+
24
+ adjustNode (node) {
25
+
26
+ node.children = node.children
27
+ .filter (i => i.localName !== 'annotation')
28
+ .map (node => this.adjustNode (node))
29
+
30
+ const {attributes, namespacesMap} = node, splitNs = name => {
31
+
32
+ if (!attributes.has (name)) return
33
+
34
+ const value = attributes.get (name), pos = value.indexOf (':')
35
+
36
+ attributes.set (name,
37
+
38
+ pos === -1 ? [value, this.targetNamespace] :
39
+
40
+ [value.substring (pos + 1), namespacesMap.get (value.substring (0, pos))]
41
+
42
+ )
43
+
44
+ }
45
+
46
+ switch (node.localName) {
47
+
48
+ case 'attribute':
49
+ case 'attributeGroup':
50
+ case 'element':
51
+ case 'group':
52
+ splitNs ('ref')
53
+ splitNs ('type')
54
+ break
55
+
56
+ case 'extension':
57
+ case 'restriction':
58
+ splitNs ('base')
59
+ break
60
+
61
+ }
62
+
63
+ return node
64
+
65
+ }
59
66
 
60
67
  getType (localName) {
61
68
 
@@ -65,7 +72,7 @@ const XMLSchema = class extends Map {
65
72
 
66
73
  setSource (node) {
67
74
 
68
- node = adjustNode (node).detach ()
75
+ node = this.adjustNode (node).detach ()
69
76
 
70
77
  const {attributes, children} = node
71
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-toolkit",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "description": "XML parser, marshaller, SOAP adapter",
5
5
  "main": "index.js",
6
6
  "files": [