cda-schematron-validator 1.0.4 → 1.0.7

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/validator.js CHANGED
@@ -1,233 +1,455 @@
1
- // jshint node:true
2
- // jshint shadow:true
3
-
4
- module.exports = {
5
- validate: validate,
6
- clearCache: clearCache,
7
- parseSchematron: require('./parseSchematron')
8
- };
9
-
10
- const fs = require('fs');
11
- const xpath = require('xpath');
12
- const dom = require('@xmldom/xmldom').DOMParser;
13
- // crypto is now built-in node
14
- const crypto = require('crypto');
15
- const _get = require('lodash.get');
16
- const parseSchematron = require('./parseSchematron');
17
- const testAssertion = require('./testAssertion');
18
- const includeExternalDocument = require('./includeExternalDocument');
19
-
20
- // Parsed object cache
21
- let parsedMap = Object.create({});
22
- let contextMap = Object.create({});
23
-
24
- function clearCache() {
25
- parsedMap = Object.create({});
26
- contextMap = Object.create({});
27
- }
28
- let namespaceMap, patternRuleMap, ruleAssertionMap, xpathSelect;
29
- function validate(xml, schematron, options = {}) {
30
- // If not valid xml, it might be a filepath
31
- // Adding explicit check to make it clear
32
- if (xml.trim().indexOf('<') === -1) {
33
- try {
34
- xml = fs.readFileSync(xml, 'utf-8').toString();
35
- }
36
- catch (err) {
37
- // If no valid xml found, inform user, and return immediately
38
- console.log('No valid xml could be found');
39
- return;
40
- }
41
- }
42
-
43
- let schematronMap;
44
- // Load xml doc
45
- let xmlDoc = new dom().parseFromString(xml);
46
- // Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
47
- if (options.parsedSchematronMap) {
48
- schematronMap = options.parsedSchematronMap;
49
- }
50
- else {
51
- // If not valid schematron (xml), it might be a filepath
52
- // Adding explicit check to make it clear
53
- if (schematron.trim().indexOf('<') === -1) {
54
- try {
55
- schematron = fs.readFileSync(schematron, 'utf-8').toString();
56
- }
57
- catch (err) {
58
- // If no valid schematron found, inform user, and return immediately
59
- console.log('No valid schematron could be found');
60
- return;
61
- }
62
- }
63
- let hash = crypto
64
- .createHash('md5')
65
- .update(schematron)
66
- .digest('hex');
67
- schematronMap = parsedMap[hash];
68
- // If not in cache
69
- if (!schematronMap) {
70
- // Load schematron doc
71
- let schematronDoc = new dom().parseFromString(schematron);
72
-
73
- // Parse schematron
74
- schematronMap = parseSchematron(schematronDoc);
75
-
76
- // Cache parsed schematron
77
- parsedMap[hash] = schematronMap;
78
- }
79
- }
80
-
81
- // Extract data from parsed schematron object
82
- namespaceMap = schematronMap.namespaceMap;
83
- patternRuleMap = schematronMap.patternRuleMap;
84
- ruleAssertionMap = schematronMap.ruleAssertionMap;
85
-
86
- // Create selector object, initialized with namespaces
87
- // Avoid using 'select' as a variable name as it is overused
88
- xpathSelect = xpath.useNamespaces(namespaceMap);
89
-
90
- let errors = [];
91
- let warnings = [];
92
- let ignored = [];
93
- for (let patternId in patternRuleMap) {
94
- if (!patternRuleMap.hasOwnProperty(patternId)) {
95
- continue;
96
- }
97
- const rules = patternRuleMap[patternId];
98
- for (let i = 0; i < rules.length; i++) {
99
- const ruleId = rules[i];
100
- const ruleObject = ruleAssertionMap[ruleId];
101
- if (_get(ruleObject, 'abstract')) {
102
- continue;
103
- }
104
- const context = _get(ruleObject, 'context');
105
- const assertionsAndExtensions = _get(ruleObject, 'assertionsAndExtensions') || [];
106
- let failedAssertions = checkRule(xmlDoc, context, assertionsAndExtensions, options);
107
- for (let j = 0; j < failedAssertions.length; j++) {
108
- const assertionObject = failedAssertions[j];
109
- const { type, assertionId, test, simplifiedTest, description, errorMessage, results } = assertionObject;
110
- if (!results.ignored) {
111
- for (let k = 0; k < results.length; k++) {
112
- const resultObject = results[k];
113
- const { result, line, path, xml } = resultObject;
114
- if (!result) {
115
- let obj = {
116
- type: type,
117
- test: test,
118
- simplifiedTest: simplifiedTest,
119
- description: description,
120
- line: line,
121
- path: path,
122
- patternId: patternId,
123
- ruleId: ruleId,
124
- assertionId: assertionId,
125
- context: context,
126
- xml: xml
127
- };
128
- if (type === 'error') {
129
- errors.push(obj);
130
- }
131
- else {
132
- warnings.push(obj);
133
- }
134
- }
135
- }
136
- }
137
- else {
138
- let obj = {
139
- errorMessage: errorMessage,
140
- type: type,
141
- test: test,
142
- simplifiedTest: simplifiedTest,
143
- description: description,
144
- patternId: patternId,
145
- ruleId: ruleId,
146
- assertionId: assertionId,
147
- context: context
148
- };
149
- ignored.push(obj);
150
- }
151
- }
152
- }
153
- }
154
-
155
- return {
156
- errorCount: errors.length,
157
- warningCount: warnings.length,
158
- ignoredCount: ignored.length,
159
- errors: errors,
160
- warnings: warnings,
161
- ignored: ignored
162
- };
163
- }
164
-
165
- // Take the checkRule function out of validate function, and pass on the variable needed as parameters and options
166
- function checkRule(xmlDoc, originalContext, assertionsAndExtensions, options) {
167
- // Context cache
168
- const includeWarnings = options.includeWarnings === undefined ? true : options.includeWarnings;
169
- const resourceDir = options.resourceDir || './';
170
- const xmlSnippetMaxLength = options.xmlSnippetMaxLength === undefined ? 200 : options.xmlSnippetMaxLength;
171
- let results = [];
172
- const context = options.contextOverride || originalContext;
173
- // Determine the sections within context, load selected section from cache if possible
174
- let selected = contextMap[context];
175
- let contextModified = context;
176
- if (!selected) {
177
- if (context) {
178
- if (context.indexOf('/')) {
179
- contextModified = '//' + context;
180
- }
181
- selected = xpathSelect(contextModified, xmlDoc);
182
- }
183
- else {
184
- selected = [xmlDoc];
185
- }
186
- contextMap[context] = selected;
187
- }
188
-
189
- for (let i = 0; i < assertionsAndExtensions.length; i++) {
190
- const assertionAndExtensionObject = assertionsAndExtensions[i];
191
- if (assertionAndExtensionObject.type === 'assertion') {
192
- let { level, test, id, description } = assertionAndExtensionObject;
193
-
194
- // Extract values from external document and modify test if a document call is made
195
- let originalTest = test;
196
- try {
197
- test = includeExternalDocument(test, resourceDir);
198
- }
199
- catch (err) {
200
- return { ignored: true, errorMessage: err.message };
201
- }
202
-
203
- let simplifiedTest = null;
204
- if (originalTest !== test) {
205
- simplifiedTest = test;
206
- }
207
- if (level === 'error' || includeWarnings) {
208
- results.push({
209
- type: level,
210
- assertionId: id,
211
- test: originalTest,
212
- simplifiedTest: simplifiedTest,
213
- description: description,
214
- results: testAssertion(test, selected, xpathSelect, xmlDoc, resourceDir, xmlSnippetMaxLength)
215
- });
216
- }
217
- }
218
- else {
219
- const extensionRule = assertionAndExtensionObject.rule;
220
- if (!extensionRule) {
221
- continue;
222
- }
223
- const subAssertionsAndExtensions = ruleAssertionMap[extensionRule] ? ruleAssertionMap[extensionRule].assertionsAndExtensions : null;
224
- if (!subAssertionsAndExtensions) {
225
- continue;
226
- }
227
- const newRuleObject = ruleAssertionMap[extensionRule];
228
- const newContext = newRuleObject.context;
229
- results = results.concat(checkRule(xmlDoc, newContext, subAssertionsAndExtensions, options));
230
- }
231
- }
232
- return results;
233
- }
1
+ // jshint node:true
2
+ // jshint shadow:true
3
+
4
+ module.exports = {
5
+ validate: validate,
6
+ validateAsync: validateAsync,
7
+ clearCache: clearCache,
8
+ parseSchematron: require('./parseSchematron')
9
+ };
10
+
11
+ const fs = require('fs');
12
+ const xpath = require('xpath');
13
+ const dom = require('@xmldom/xmldom').DOMParser;
14
+ // crypto is now built-in node
15
+ const crypto = require('crypto');
16
+ const _get = require('lodash.get');
17
+ const parseSchematron = require('./parseSchematron');
18
+ const testAssertion = require('./testAssertion');
19
+ const includeExternalDocument = require('./includeExternalDocument');
20
+
21
+ // Parsed object cache
22
+ let parsedMap = Object.create({});
23
+ let contextMap = Object.create({});
24
+
25
+ function clearCache() {
26
+ parsedMap = Object.create({});
27
+ contextMap = Object.create({});
28
+ }
29
+ let namespaceMap, patternRuleMap, ruleAssertionMap, xpathSelect;
30
+ function validate(xml, schematron, options = {}) {
31
+ // If not valid xml, it might be a filepath
32
+ // Adding explicit check to make it clear
33
+ if (xml.trim().indexOf('<') === -1) {
34
+ try {
35
+ xml = fs.readFileSync(xml, 'utf-8').toString();
36
+ }
37
+ catch (err) {
38
+ // If no valid xml found, inform user, and return immediately
39
+ console.log('No valid xml could be found');
40
+ return;
41
+ }
42
+ }
43
+
44
+ let schematronMap;
45
+ // Load xml doc
46
+ let xmlDoc = new dom().parseFromString(xml);
47
+ // Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
48
+ if (options.parsedSchematronMap) {
49
+ schematronMap = options.parsedSchematronMap;
50
+ }
51
+ else {
52
+ // If not valid schematron (xml), it might be a filepath
53
+ // Adding explicit check to make it clear
54
+ if (schematron.trim().indexOf('<') === -1) {
55
+ try {
56
+ schematron = fs.readFileSync(schematron, 'utf-8').toString();
57
+ }
58
+ catch (err) {
59
+ // If no valid schematron found, inform user, and return immediately
60
+ console.log('No valid schematron could be found');
61
+ return;
62
+ }
63
+ }
64
+ let hash = crypto
65
+ .createHash('md5')
66
+ .update(schematron)
67
+ .digest('hex');
68
+ schematronMap = parsedMap[hash];
69
+ // If not in cache
70
+ if (!schematronMap) {
71
+ // Load schematron doc
72
+ let schematronDoc = new dom().parseFromString(schematron);
73
+
74
+ // Parse schematron
75
+ schematronMap = parseSchematron(schematronDoc);
76
+
77
+ // Cache parsed schematron
78
+ parsedMap[hash] = schematronMap;
79
+ }
80
+ }
81
+
82
+ // Extract data from parsed schematron object
83
+ namespaceMap = schematronMap.namespaceMap;
84
+ patternRuleMap = schematronMap.patternRuleMap;
85
+ ruleAssertionMap = schematronMap.ruleAssertionMap;
86
+
87
+ // Create selector object, initialized with namespaces
88
+ // Avoid using 'select' as a variable name as it is overused
89
+ xpathSelect = xpath.useNamespaces(namespaceMap);
90
+
91
+ let errors = [];
92
+ let warnings = [];
93
+ let ignored = [];
94
+ for (let patternId in patternRuleMap) {
95
+ if (!patternRuleMap.hasOwnProperty(patternId)) {
96
+ continue;
97
+ }
98
+ const rules = patternRuleMap[patternId];
99
+ for (let i = 0; i < rules.length; i++) {
100
+ const ruleId = rules[i];
101
+ const ruleObject = ruleAssertionMap[ruleId];
102
+ if (_get(ruleObject, 'abstract')) {
103
+ continue;
104
+ }
105
+ const context = _get(ruleObject, 'context');
106
+ const assertionsAndExtensions = _get(ruleObject, 'assertionsAndExtensions') || [];
107
+ let failedAssertions = checkRule(xmlDoc, context, assertionsAndExtensions, options);
108
+ for (let j = 0; j < failedAssertions.length; j++) {
109
+ const assertionObject = failedAssertions[j];
110
+ const { type, assertionId, test, simplifiedTest, description, errorMessage, results } = assertionObject;
111
+ if (!results.ignored) {
112
+ for (let k = 0; k < results.length; k++) {
113
+ const resultObject = results[k];
114
+ const { result, line, path, xml } = resultObject;
115
+ if (!result) {
116
+ let obj = {
117
+ type: type,
118
+ test: test,
119
+ simplifiedTest: simplifiedTest,
120
+ description: description,
121
+ line: line,
122
+ path: path,
123
+ patternId: patternId,
124
+ ruleId: ruleId,
125
+ assertionId: assertionId,
126
+ context: context,
127
+ xml: xml
128
+ };
129
+ if (type === 'error') {
130
+ errors.push(obj);
131
+ }
132
+ else {
133
+ warnings.push(obj);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ else {
139
+ let obj = {
140
+ errorMessage: errorMessage,
141
+ type: type,
142
+ test: test,
143
+ simplifiedTest: simplifiedTest,
144
+ description: description,
145
+ patternId: patternId,
146
+ ruleId: ruleId,
147
+ assertionId: assertionId,
148
+ context: context
149
+ };
150
+ ignored.push(obj);
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ return {
157
+ errorCount: errors.length,
158
+ warningCount: warnings.length,
159
+ ignoredCount: ignored.length,
160
+ errors: errors,
161
+ warnings: warnings,
162
+ ignored: ignored
163
+ };
164
+ }
165
+
166
+ // Take the checkRule function out of validate function, and pass on the variable needed as parameters and options
167
+ function checkRule(xmlDoc, originalContext, assertionsAndExtensions, options) {
168
+ // Context cache
169
+ const includeWarnings = options.includeWarnings === undefined ? true : options.includeWarnings;
170
+ const resourceDir = options.resourceDir || './';
171
+ const xmlSnippetMaxLength = options.xmlSnippetMaxLength === undefined ? 200 : options.xmlSnippetMaxLength;
172
+ let results = [];
173
+ const context = options.contextOverride || originalContext;
174
+ // Determine the sections within context, load selected section from cache if possible
175
+ let selected = contextMap[context];
176
+ let contextModified = context;
177
+ if (!selected) {
178
+ if (context) {
179
+ if (context.indexOf('/')) {
180
+ contextModified = '//' + context;
181
+ }
182
+ selected = xpathSelect(contextModified, xmlDoc);
183
+ }
184
+ else {
185
+ selected = [xmlDoc];
186
+ }
187
+ contextMap[context] = selected;
188
+ }
189
+
190
+ for (let i = 0; i < assertionsAndExtensions.length; i++) {
191
+ const assertionAndExtensionObject = assertionsAndExtensions[i];
192
+ if (assertionAndExtensionObject.type === 'assertion') {
193
+ let { level, test, id, description } = assertionAndExtensionObject;
194
+
195
+ // Extract values from external document and modify test if a document call is made
196
+ let originalTest = test;
197
+ try {
198
+ test = includeExternalDocument(test, resourceDir);
199
+ }
200
+ catch (err) {
201
+ return { ignored: true, errorMessage: err.message };
202
+ }
203
+
204
+ let simplifiedTest = null;
205
+ if (originalTest !== test) {
206
+ simplifiedTest = test;
207
+ }
208
+ if (level === 'error' || includeWarnings) {
209
+ results.push({
210
+ type: level,
211
+ assertionId: id,
212
+ test: originalTest,
213
+ simplifiedTest: simplifiedTest,
214
+ description: description,
215
+ results: testAssertion(test, selected, xpathSelect, xmlDoc, resourceDir, xmlSnippetMaxLength)
216
+ });
217
+ }
218
+ }
219
+ else {
220
+ const extensionRule = assertionAndExtensionObject.rule;
221
+ if (!extensionRule) {
222
+ continue;
223
+ }
224
+ const subAssertionsAndExtensions = ruleAssertionMap[extensionRule] ? ruleAssertionMap[extensionRule].assertionsAndExtensions : null;
225
+ if (!subAssertionsAndExtensions) {
226
+ continue;
227
+ }
228
+ const newRuleObject = ruleAssertionMap[extensionRule];
229
+ const newContext = newRuleObject.context;
230
+ results = results.concat(checkRule(xmlDoc, newContext, subAssertionsAndExtensions, options));
231
+ }
232
+ }
233
+ return results;
234
+ }
235
+
236
+ async function validateAsync(xml, schematron, options = {}) {
237
+ // If not valid xml, it might be a filepath
238
+ // Adding explicit check to make it clear
239
+ if (xml.trim().indexOf('<') === -1) {
240
+ try {
241
+ xml = fs.readFileSync(xml, 'utf-8').toString();
242
+ }
243
+ catch (err) {
244
+ // If no valid xml found, inform user, and return immediately
245
+ console.log('No valid xml could be found');
246
+ return;
247
+ }
248
+ }
249
+
250
+ let schematronMap;
251
+ // Load xml doc
252
+ let xmlDoc = new dom().parseFromString(xml);
253
+ // Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
254
+ if (options.parsedSchematronMap) {
255
+ schematronMap = options.parsedSchematronMap;
256
+ }
257
+ else {
258
+ // If not valid schematron (xml), it might be a filepath
259
+ // Adding explicit check to make it clear
260
+ if (schematron.trim().indexOf('<') === -1) {
261
+ try {
262
+ schematron = fs.readFileSync(schematron, 'utf-8').toString();
263
+ }
264
+ catch (err) {
265
+ // If no valid schematron found, inform user, and return immediately
266
+ console.log('No valid schematron could be found');
267
+ return;
268
+ }
269
+ }
270
+ let hash = crypto
271
+ .createHash('md5')
272
+ .update(schematron)
273
+ .digest('hex');
274
+ schematronMap = parsedMap[hash];
275
+ // If not in cache
276
+ if (!schematronMap) {
277
+ // Load schematron doc
278
+ let schematronDoc = new dom().parseFromString(schematron);
279
+
280
+ // Parse schematron
281
+ schematronMap = parseSchematron(schematronDoc);
282
+
283
+ // Cache parsed schematron
284
+ parsedMap[hash] = schematronMap;
285
+ }
286
+ }
287
+
288
+ // Extract data from parsed schematron object
289
+ namespaceMap = schematronMap.namespaceMap;
290
+ patternRuleMap = schematronMap.patternRuleMap;
291
+ ruleAssertionMap = schematronMap.ruleAssertionMap;
292
+
293
+ // Create selector object, initialized with namespaces
294
+ // Avoid using 'select' as a variable name as it is overused
295
+ xpathSelect = xpath.useNamespaces(namespaceMap);
296
+
297
+ let errors = [];
298
+ let warnings = [];
299
+ let ignored = [];
300
+ for (let patternId in patternRuleMap) {
301
+ if (!patternRuleMap.hasOwnProperty(patternId)) {
302
+ continue;
303
+ }
304
+ const rules = patternRuleMap[patternId];
305
+ for (let i = 0; i < rules.length; i++) {
306
+ const ruleId = rules[i];
307
+ const ruleObject = ruleAssertionMap[ruleId];
308
+ if (_get(ruleObject, 'abstract')) {
309
+ continue;
310
+ }
311
+ const context = _get(ruleObject, 'context');
312
+ const assertionsAndExtensions = _get(ruleObject, 'assertionsAndExtensions') || [];
313
+ let failedAssertions;
314
+ try {
315
+ failedAssertions = await checkRulePromise(xmlDoc, context, assertionsAndExtensions, options);
316
+ }
317
+ catch (errorInRuleCheck) {
318
+ console.log(errorInRuleCheck);
319
+ continue;
320
+ }
321
+ for (let j = 0; j < failedAssertions.length; j++) {
322
+ const assertionObject = failedAssertions[j];
323
+ const { type, assertionId, test, simplifiedTest, description, errorMessage, results } = assertionObject;
324
+ if (!results.ignored) {
325
+ for (let k = 0; k < results.length; k++) {
326
+ const resultObject = results[k];
327
+ const { result, line, path, xml } = resultObject;
328
+ if (!result) {
329
+ let obj = {
330
+ type: type,
331
+ test: test,
332
+ simplifiedTest: simplifiedTest,
333
+ description: description,
334
+ line: line,
335
+ path: path,
336
+ patternId: patternId,
337
+ ruleId: ruleId,
338
+ assertionId: assertionId,
339
+ context: context,
340
+ xml: xml
341
+ };
342
+ if (type === 'error') {
343
+ errors.push(obj);
344
+ }
345
+ else {
346
+ warnings.push(obj);
347
+ }
348
+ }
349
+ }
350
+ }
351
+ else {
352
+ let obj = {
353
+ errorMessage: errorMessage,
354
+ type: type,
355
+ test: test,
356
+ simplifiedTest: simplifiedTest,
357
+ description: description,
358
+ patternId: patternId,
359
+ ruleId: ruleId,
360
+ assertionId: assertionId,
361
+ context: context
362
+ };
363
+ ignored.push(obj);
364
+ }
365
+ }
366
+ }
367
+ }
368
+
369
+ return {
370
+ errorCount: errors.length,
371
+ warningCount: warnings.length,
372
+ ignoredCount: ignored.length,
373
+ errors: errors,
374
+ warnings: warnings,
375
+ ignored: ignored
376
+ };
377
+ }
378
+
379
+ // Take the checkRule function out of validate function, and pass on the variable needed as parameters and options
380
+ function checkRulePromise(xmlDoc, originalContext, assertionsAndExtensions, options) {
381
+ // Context cache
382
+ const resultCapture = new Promise((resolve, reject) => {
383
+ try {
384
+ const includeWarnings = options.includeWarnings === undefined ? true : options.includeWarnings;
385
+ const resourceDir = options.resourceDir || './';
386
+ const xmlSnippetMaxLength = options.xmlSnippetMaxLength === undefined ? 200 : options.xmlSnippetMaxLength;
387
+ let results = [];
388
+ const context = options.contextOverride || originalContext;
389
+ // Determine the sections within context, load selected section from cache if possible
390
+ let selected = contextMap[context];
391
+ let contextModified = context;
392
+ if (!selected) {
393
+ if (context) {
394
+ if (context.indexOf('/')) {
395
+ contextModified = '//' + context;
396
+ }
397
+ selected = xpathSelect(contextModified, xmlDoc);
398
+ }
399
+ else {
400
+ selected = [xmlDoc];
401
+ }
402
+ contextMap[context] = selected;
403
+ }
404
+
405
+ for (let i = 0; i < assertionsAndExtensions.length; i++) {
406
+ const assertionAndExtensionObject = assertionsAndExtensions[i];
407
+ if (assertionAndExtensionObject.type === 'assertion') {
408
+ let { level, test, id, description } = assertionAndExtensionObject;
409
+
410
+ // Extract values from external document and modify test if a document call is made
411
+ let originalTest = test;
412
+ try {
413
+ test = includeExternalDocument(test, resourceDir);
414
+ }
415
+ catch (err) {
416
+ return { ignored: true, errorMessage: err.message };
417
+ }
418
+
419
+ let simplifiedTest = null;
420
+ if (originalTest !== test) {
421
+ simplifiedTest = test;
422
+ }
423
+ if (level === 'error' || includeWarnings) {
424
+ results.push({
425
+ type: level,
426
+ assertionId: id,
427
+ test: originalTest,
428
+ simplifiedTest: simplifiedTest,
429
+ description: description,
430
+ results: testAssertion(test, selected, xpathSelect, xmlDoc, resourceDir, xmlSnippetMaxLength)
431
+ });
432
+ }
433
+ }
434
+ else {
435
+ const extensionRule = assertionAndExtensionObject.rule;
436
+ if (!extensionRule) {
437
+ continue;
438
+ }
439
+ const subAssertionsAndExtensions = ruleAssertionMap[extensionRule] ? ruleAssertionMap[extensionRule].assertionsAndExtensions : null;
440
+ if (!subAssertionsAndExtensions) {
441
+ continue;
442
+ }
443
+ const newRuleObject = ruleAssertionMap[extensionRule];
444
+ const newContext = newRuleObject.context;
445
+ results = results.concat(checkRulePromise(xmlDoc, newContext, subAssertionsAndExtensions, options));
446
+ }
447
+ }
448
+ resolve (results);
449
+ }
450
+ catch (promiseError) {
451
+ reject (new Error (`Promise Error: ${promiseError}`));
452
+ }
453
+ });
454
+ return resultCapture;
455
+ }