xml-toolkit 1.0.2 → 1.0.3
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/XMLMarshaller.js +16 -10
- package/package.json +1 -1
- package/test/20040.wsdl +1812 -0
- package/test/sign.xsd +71 -0
- package/test/test.js +48 -0
package/lib/XMLMarshaller.js
CHANGED
|
@@ -37,11 +37,11 @@ const XMLMarshaller = class {
|
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
stringify (content) {
|
|
40
|
+
stringify (content, name) {
|
|
41
41
|
|
|
42
|
-
const qName = this.ns.QName (this.schemaElement.name, this.schema.targetNamespace)
|
|
42
|
+
const qName = this.ns.QName (name || this.schemaElement.name, this.schema.targetNamespace)
|
|
43
43
|
|
|
44
|
-
const {complexType} = this.schemaElement
|
|
44
|
+
const {complexType, sequence, choice, all} = this.schemaElement, group = sequence || choice || all
|
|
45
45
|
|
|
46
46
|
let buf = ['<' + qName]
|
|
47
47
|
|
|
@@ -50,8 +50,9 @@ const XMLMarshaller = class {
|
|
|
50
50
|
if (complexType) this._aComplexType (buf, complexType, content)
|
|
51
51
|
|
|
52
52
|
buf [0] += '>'
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
if (complexType) this._bComplexType (buf, complexType, content)
|
|
55
|
+
if (group) this._bSequence (buf, group, content)
|
|
55
56
|
|
|
56
57
|
return buf [0] + '</' + qName + '>'
|
|
57
58
|
|
|
@@ -163,7 +164,7 @@ const XMLMarshaller = class {
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
to_string (v, type, restriction = {}) {
|
|
166
|
-
|
|
167
|
+
|
|
167
168
|
const carp = () => {throw new Error (`Invalid value for ${type} type: ${v} (${typeof v})`)}
|
|
168
169
|
|
|
169
170
|
switch (type) {
|
|
@@ -192,6 +193,7 @@ const XMLMarshaller = class {
|
|
|
192
193
|
case 'dateTime':
|
|
193
194
|
switch (typeof v) {
|
|
194
195
|
case 'string':
|
|
196
|
+
if (v.length === 10) return v + 'T00:00:00'
|
|
195
197
|
return v
|
|
196
198
|
case 'number':
|
|
197
199
|
case 'bigint':
|
|
@@ -286,16 +288,20 @@ const XMLMarshaller = class {
|
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
_bSequence (buf, _sequence, content) {
|
|
289
|
-
|
|
291
|
+
|
|
290
292
|
const {element, sequence, choice, all} = _sequence, group = sequence || choice || all
|
|
291
293
|
|
|
292
294
|
if (group) this._bSequence (buf, group, content)
|
|
293
295
|
|
|
294
296
|
if (element) {
|
|
295
|
-
|
|
296
|
-
for (const e of Array.isArray (element) ? element : [element])
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
|
|
298
|
+
for (const e of Array.isArray (element) ? element : [element]) {
|
|
299
|
+
|
|
300
|
+
const c = content [e.name]
|
|
301
|
+
|
|
302
|
+
this._bElement (buf, e, c)
|
|
303
|
+
|
|
304
|
+
}
|
|
299
305
|
|
|
300
306
|
}
|
|
301
307
|
|