xml-toolkit 0.0.7 → 1.0.1
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/README.md +74 -1
- package/index.js +10 -6
- package/lib/AttributesMap.js +1 -1
- package/lib/MoxyLikeJsonEncoder.js +44 -20
- package/lib/NamespacePrefixesMap.js +57 -0
- package/lib/XMLMarshaller.js +361 -0
- package/lib/XMLNode.js +9 -3
- package/lib/XMLReader.js +1 -1
- package/lib/XMLSchema.js +103 -0
- package/lib/XMLSchemata.js +143 -0
- package/package.json +6 -3
- package/test/commons/dom-gosuslugi-ru-smev3-common.xsd +465 -0
- package/test/dom-gosuslugi-ru-smev3-debt-responses.xsd +776 -0
- package/test/soap.xml +1 -1
- package/test/test.js +126 -15
package/test/soap.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<SOAP-ENV:Header/>
|
|
3
3
|
<SOAP-ENV:Body>
|
|
4
4
|
<SendRequestRequest xmlns="urn://x-artefacts-smev-gov-ru/services/message-exchange/types/1.1" xmlns:ns0="urn://x-artefacts-smev-gov-ru/services/message-exchange/types/basic/1.1">
|
|
5
|
-
<SenderProvidedRequestData Id="Ue7e71ce1-7ce3-4ca5-a689-1a8f2edbb1af">
|
|
5
|
+
<SenderProvidedRequestData Id="Ue7e71ce1-7ce3-4ca5-a689-1a8f2edbb1af" IDDQD="">
|
|
6
6
|
<MessageID>3931cda8-3245-11ec-b0bc-000c293433a0</MessageID>
|
|
7
7
|
<ns0:MessagePrimaryContent>
|
|
8
8
|
<ExportDebtRequestsRequest xmlns="urn:dom.gosuslugi.ru/debt-responses/1.0.0" xmlns:ns0="urn:dom.gosuslugi.ru/common/1.2.0">
|
package/test/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require ('fs')
|
|
2
2
|
const assert = require ('assert')
|
|
3
|
-
const {XMLReader, SAXEvent, XMLLexer, AttributesMap,
|
|
3
|
+
const {XMLReader, SAXEvent, XMLLexer, AttributesMap, XMLNode, XMLSchemata} = require ('../')
|
|
4
4
|
|
|
5
5
|
async function test_001_lexer_sync (fn) {
|
|
6
6
|
|
|
@@ -59,8 +59,12 @@ console.log (xml)
|
|
|
59
59
|
|
|
60
60
|
const sax = new XMLReader ({
|
|
61
61
|
// stripSpace: true,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
filterElements: 'SendRequestRequest',
|
|
63
|
+
map: XMLNode.toObject ({
|
|
64
|
+
// wrap: 1,
|
|
65
|
+
getName: (localName, namespaceURI) => (!namespaceURI ? '' : '{' + namespaceURI + '}') + localName,
|
|
66
|
+
map: o => Object.fromEntries (Object.entries (o).map (([k, v]) => [k + '111', v]))
|
|
67
|
+
})
|
|
64
68
|
})
|
|
65
69
|
|
|
66
70
|
/*
|
|
@@ -77,27 +81,133 @@ console.log (xml)
|
|
|
77
81
|
})
|
|
78
82
|
*/
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
// sax.process (fs.createReadStream ('test/' + fn))
|
|
82
|
-
|
|
83
|
-
sax.process (xml)
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
//console.log (sax)
|
|
86
86
|
//console.log (sax.isSAX)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
/*
|
|
89
89
|
let s = ''
|
|
90
90
|
for await (const e of sax) {
|
|
91
|
-
|
|
92
|
-
console.log ([e.type, e.isStartElement, e.isEndElement , e.isCharacters])
|
|
91
|
+
s += xml
|
|
92
|
+
// console.log ([e.type, e.isStartElement, e.isEndElement , e.isCharacters])
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
*/
|
|
95
95
|
//console.log ([xml, s])
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const v = await sax.process (xml).findFirst ()
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
console.log (JSON.stringify (v, null, 2))
|
|
100
|
+
|
|
101
|
+
}
|
|
100
102
|
|
|
103
|
+
async function test_004_schemata (fn) {
|
|
104
|
+
|
|
105
|
+
let xs = await XMLSchemata.fromFile ('test/dom-gosuslugi-ru-smev3-debt-responses.xsd')
|
|
106
|
+
/*
|
|
107
|
+
const localName = 'ImportDebtRequestsRequest'
|
|
108
|
+
|
|
109
|
+
const s = xs.getSchemaByLocalName (localName)
|
|
110
|
+
|
|
111
|
+
const o = s.get (localName)
|
|
112
|
+
|
|
113
|
+
const nspm = xs.getNamespacePrefixesMap (o)
|
|
114
|
+
*/
|
|
115
|
+
console.log (xs.stringify ({
|
|
116
|
+
"ExportDebtRequestsResponse": {
|
|
117
|
+
"request-data": {
|
|
118
|
+
"request-id": "bac4c940-6ad3-11eb-9439-0242ac130002",
|
|
119
|
+
"request-number": "022021173",
|
|
120
|
+
"applicant-info": {
|
|
121
|
+
"firstname": "Иван",
|
|
122
|
+
"lastname": "Иванов",
|
|
123
|
+
"middlename": "Иванович",
|
|
124
|
+
"snils": "11111111145",
|
|
125
|
+
"document": {
|
|
126
|
+
"type": "1",
|
|
127
|
+
"series": "1234",
|
|
128
|
+
"number": "123456"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"housing-fund-object": {
|
|
132
|
+
"house-id": "e786b770-28e6-4557-8dde-86e8e347587e",
|
|
133
|
+
"address-details": "кв. 27",
|
|
134
|
+
"fias-house-id": "497cdeef-0388-466b-a063-36f51d94800c",
|
|
135
|
+
"address": "153045, Ивановская обл, г. Иваново, ул. 3 Июня, д. 14"
|
|
136
|
+
},
|
|
137
|
+
"period": {
|
|
138
|
+
"start-date": "2018-02-01",
|
|
139
|
+
"end-date": new Date ()
|
|
140
|
+
},
|
|
141
|
+
"organization": {
|
|
142
|
+
"organization-root-id": "6eef689e-48bb-4eb0-9c11-18b6db9909b7",
|
|
143
|
+
"name": "Администрация г. Иваново",
|
|
144
|
+
"tel": "+7(4932)32-80-83"
|
|
145
|
+
},
|
|
146
|
+
"executor-info": {
|
|
147
|
+
"id": "84b12e02-6ad8-11eb-9439-0242ac130002",
|
|
148
|
+
"fio": "Четвертак Иван Иванович"
|
|
149
|
+
},
|
|
150
|
+
"status": "PROCESSED",
|
|
151
|
+
"result": 4,
|
|
152
|
+
"creation-date": "2021-02-04",
|
|
153
|
+
"sent-date": "2021-02-04",
|
|
154
|
+
"response-date": "2021-02-08",
|
|
155
|
+
"subrequest": {
|
|
156
|
+
"organization": {
|
|
157
|
+
"organization-root-id": "ad50290c-6ad9-11eb-9439-0242ac130002",
|
|
158
|
+
"name": "УК ООО \"ГУЖФ\"",
|
|
159
|
+
"tel": "8-800-200-50-58"
|
|
160
|
+
},
|
|
161
|
+
"response": {
|
|
162
|
+
"type": "PROVIDED",
|
|
163
|
+
"has-debt": true,
|
|
164
|
+
"debt-info": [
|
|
165
|
+
{
|
|
166
|
+
"person": {
|
|
167
|
+
"firstname": "Петр",
|
|
168
|
+
"lastname": "Петров",
|
|
169
|
+
"middlename": "Петрович",
|
|
170
|
+
"snils": "11111111146",
|
|
171
|
+
"document": {
|
|
172
|
+
"type": "1",
|
|
173
|
+
"series": "1235",
|
|
174
|
+
"number": "123455"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"person": {
|
|
180
|
+
"firstname": "Сидор",
|
|
181
|
+
"lastname": "Сидоров",
|
|
182
|
+
"middlename": "Сидорович",
|
|
183
|
+
"snils": "11111111146",
|
|
184
|
+
"document": {
|
|
185
|
+
"type": "1",
|
|
186
|
+
"series": "1235",
|
|
187
|
+
"number": "123455"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"executor-info": {
|
|
193
|
+
"id": "38a794b8-6ada-11eb-9439-0242ac130002",
|
|
194
|
+
"fio": "Герасимова Ольга Ивановна"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}))
|
|
201
|
+
|
|
202
|
+
//getNamespacePrefixesMap
|
|
203
|
+
/*
|
|
204
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ImportDebtRequestsRequest').complexType.complexContent.extension)
|
|
205
|
+
|
|
206
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/common/1.2.0').get ('BaseRequestType').sequence )
|
|
207
|
+
|
|
208
|
+
console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ActionType').restriction)
|
|
209
|
+
*/
|
|
210
|
+
|
|
101
211
|
}
|
|
102
212
|
|
|
103
213
|
async function main () {
|
|
@@ -113,7 +223,8 @@ async function main () {
|
|
|
113
223
|
// await test_003_emitter_sync ('param_types.xml')
|
|
114
224
|
// await test_003_emitter_sync ('not-sa01.xml')
|
|
115
225
|
// await test_003_emitter_sync ('ent.xml')
|
|
116
|
-
await test_003_emitter_sync ('soap.xml')
|
|
226
|
+
// await test_003_emitter_sync ('soap.xml')
|
|
227
|
+
await test_004_schemata ()
|
|
117
228
|
|
|
118
229
|
}
|
|
119
230
|
|