xml-toolkit 0.0.8 → 1.0.2
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 +76 -1
- package/index.js +10 -6
- package/lib/MoxyLikeJsonEncoder.js +41 -23
- package/lib/NamespacePrefixesMap.js +57 -0
- package/lib/XMLMarshaller.js +363 -0
- package/lib/XMLNode.js +9 -3
- 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/test.js +118 -3
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
|
|
|
@@ -60,7 +60,11 @@ console.log (xml)
|
|
|
60
60
|
const sax = new XMLReader ({
|
|
61
61
|
// stripSpace: true,
|
|
62
62
|
filterElements: 'SendRequestRequest',
|
|
63
|
-
map:
|
|
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
|
/*
|
|
@@ -96,6 +100,116 @@ console.log (xml)
|
|
|
96
100
|
|
|
97
101
|
}
|
|
98
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
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
99
213
|
async function main () {
|
|
100
214
|
|
|
101
215
|
// await test_001_lexer_sync ('E05a.xml')
|
|
@@ -109,7 +223,8 @@ async function main () {
|
|
|
109
223
|
// await test_003_emitter_sync ('param_types.xml')
|
|
110
224
|
// await test_003_emitter_sync ('not-sa01.xml')
|
|
111
225
|
// await test_003_emitter_sync ('ent.xml')
|
|
112
|
-
await test_003_emitter_sync ('soap.xml')
|
|
226
|
+
// await test_003_emitter_sync ('soap.xml')
|
|
227
|
+
await test_004_schemata ()
|
|
113
228
|
|
|
114
229
|
}
|
|
115
230
|
|