cda-schematron-validator 1.1.12 → 2.0.0-preview.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.
Files changed (48) hide show
  1. package/LICENSE.md +9 -9
  2. package/README.md +222 -243
  3. package/bin/cda-validate.js +36 -0
  4. package/docs/api.md +134 -0
  5. package/docs/architecture.md +102 -0
  6. package/docs/coverage.md +112 -0
  7. package/docs/deployment.md +126 -0
  8. package/docs/history.md +245 -0
  9. package/docs/legacy-api.md +70 -0
  10. package/lib/checkIfFileOrPath.js +27 -28
  11. package/lib/checkRule.js +97 -98
  12. package/lib/createClient.js +35 -0
  13. package/lib/getAssertionObject.js +23 -23
  14. package/lib/getErrorsAndWarnings.js +41 -41
  15. package/lib/getFailedAssertions.js +24 -25
  16. package/lib/getIgnored.js +27 -27
  17. package/lib/getResults.js +22 -22
  18. package/lib/getReturnObject.js +20 -20
  19. package/lib/getSchematronMap.js +34 -31
  20. package/lib/getSelectXmlChunk.js +27 -27
  21. package/lib/includeExternalDocument.js +113 -107
  22. package/lib/initializeProcess.js +34 -40
  23. package/lib/parseSchematron.js +122 -122
  24. package/lib/processFailedAssertions.js +17 -17
  25. package/lib/processRules.js +20 -20
  26. package/lib/processRulesAsync.js +18 -30
  27. package/lib/testAssertion.js +74 -74
  28. package/package.json +67 -59
  29. package/validateAsync.js +103 -117
  30. package/validateSync.js +51 -55
  31. package/validator.d.ts +87 -0
  32. package/validator.js +17 -16
  33. package/.eslintrc.js +0 -30
  34. package/.github/workflows/codeql-analysis.yml +0 -70
  35. package/.husky/pre-commit +0 -5
  36. package/.jshintrc +0 -96
  37. package/.vscode/launch.json +0 -37
  38. package/Gruntfile.js +0 -28
  39. package/SECURITY.md +0 -21
  40. package/test/CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2015AUG_Vol2_2019JUNwith_errata.sch +0 -71
  41. package/test/VitalSigns.xml +0 -856
  42. package/test/async.test.js +0 -124
  43. package/test/asyncFileList.test.js +0 -61
  44. package/test/test.sch +0 -47
  45. package/test/test.xml +0 -80
  46. package/test/tests.js +0 -140
  47. package/test/vitalSigns.test.js +0 -34
  48. package/test/voc.xml +0 -44
@@ -1,107 +1,113 @@
1
- // jshint node:true
2
- // jshint shadow:true
3
- module.exports = modifyTest;
4
-
5
- const fs = require('fs');
6
- const xpath = require('xpath');
7
- const Dom = require('@xmldom/xmldom').DOMParser;
8
- const path = require('path');
9
-
10
- const loadedExternalDocuments = Object.create({});
11
-
12
- function modifyTest(test, resourceDir) {
13
- let matches = /=document\((\'[-_.A-Za-z0-9]+\'|\"[-_.A-Za-z0-9]+\")\)/.exec(test);
14
- while (matches) {
15
- // String processing to select the non-regular predicate expression
16
- const equalInd = test.indexOf(matches[0]);
17
- let start = equalInd;
18
- let bracketDepth = 0;
19
- for (let i = equalInd; i >= 0; i--) {
20
- if (!bracketDepth && (test[i] === '[' || test[i] === ' ')) {
21
- start = i + 1;
22
- break;
23
- }
24
- if (test[i] === ']') {
25
- bracketDepth++;
26
- }
27
- else if (test[i] === '[') {
28
- bracketDepth--;
29
- }
30
- }
31
-
32
- let end = test.length;
33
- bracketDepth = 0;
34
- for (let i = start + matches[0].length; i < test.length; i++) {
35
- if (!bracketDepth && (test[i] === ']' || test[i] === ' ')) {
36
- end = i;
37
- break;
38
- }
39
- if (test[i] === '[') {
40
- bracketDepth++;
41
- }
42
- else if (test[i] === ']') {
43
- bracketDepth--;
44
- }
45
- }
46
-
47
- const predicate = test.slice(start, end);
48
-
49
- // Load external doc (load from "cache" if already loaded)
50
- const filepath = matches[1].slice(1, -1);
51
- let externalDoc;
52
- if (!loadedExternalDocuments[filepath]) {
53
- let externalXml = null;
54
- try {
55
- externalXml = fs.readFileSync(path.join(resourceDir, filepath), 'utf-8').toString();
56
- }
57
- catch (err) {
58
- throw new Error('No such file \'' + filepath + '\'');
59
- }
60
- externalDoc = new Dom().parseFromString(externalXml);
61
- loadedExternalDocuments[filepath] = externalDoc;
62
- }
63
- else {
64
- externalDoc = loadedExternalDocuments[filepath];
65
- }
66
-
67
- const externalXpath = test.slice(equalInd + matches[0].length, end);
68
-
69
- // Extract namespaces
70
- const defaultNamespaceKey = /([^(<>.\/)]+):[^(<>.\/)]+/.exec(externalXpath)[1];
71
- const externalNamespaceMap = externalDoc.lastChild._nsMap;
72
- const namespaceMap = {};
73
- for (const key in externalNamespaceMap) {
74
- if (externalNamespaceMap.hasOwnProperty(key)) {
75
- if (key) {
76
- namespaceMap[key] = externalNamespaceMap[key];
77
- }
78
- }
79
- }
80
- namespaceMap[defaultNamespaceKey] = externalNamespaceMap[''];
81
-
82
- const externalSelect = xpath.useNamespaces(namespaceMap);
83
-
84
- // Create new predicate from extract values
85
- const values = [];
86
- const externalResults = externalSelect(externalXpath, externalDoc);
87
- for (let i = 0; i < externalResults.length; i++) {
88
- values.push(externalResults[i].value);
89
- }
90
- const lhv = predicate.slice(0, predicate.indexOf('=document('));
91
- let newPredicate = '(';
92
- for (let i = 0; i < values.length; i++) {
93
- newPredicate += lhv + '=\'' + values[i] + '\'';
94
- if (i < values.length - 1) {
95
- newPredicate += ' or ';
96
- }
97
- }
98
- newPredicate += ')';
99
-
100
- // Replace test
101
- test = test.slice(0, start) + newPredicate + test.slice(end);
102
-
103
- matches = /@[^\[\]]+=document\((\'[-_.A-Za-z0-9]+\'|\"[-_.A-Za-z0-9]+\")\)/.exec(test);
104
- }
105
-
106
- return test;
107
- }
1
+ // jshint node:true
2
+ // jshint shadow:true
3
+ module.exports = modifyTest;
4
+
5
+ const fs = require('fs');
6
+ const xpath = require('xpath');
7
+ const Dom = require('@xmldom/xmldom').DOMParser;
8
+ const path = require('path');
9
+
10
+ const loadedExternalDocuments = Object.create(null);
11
+
12
+ function modifyTest(test, resourceDir) {
13
+ let matches = /=document\((\'[-_.A-Za-z0-9]+\'|\"[-_.A-Za-z0-9]+\")\)/.exec(test);
14
+ while (matches) {
15
+ // String processing to select the non-regular predicate expression
16
+ const equalInd = test.indexOf(matches[0]);
17
+ let start = equalInd;
18
+ let bracketDepth = 0;
19
+ for (let i = equalInd; i >= 0; i--) {
20
+ if (!bracketDepth && (test[i] === '[' || test[i] === ' ')) {
21
+ start = i + 1;
22
+ break;
23
+ }
24
+ if (test[i] === ']') {
25
+ bracketDepth++;
26
+ }
27
+ else if (test[i] === '[') {
28
+ bracketDepth--;
29
+ }
30
+ }
31
+
32
+ let end = test.length;
33
+ bracketDepth = 0;
34
+ for (let i = start + matches[0].length; i < test.length; i++) {
35
+ if (!bracketDepth && (test[i] === ']' || test[i] === ' ')) {
36
+ end = i;
37
+ break;
38
+ }
39
+ if (test[i] === '[') {
40
+ bracketDepth++;
41
+ }
42
+ else if (test[i] === ']') {
43
+ bracketDepth--;
44
+ }
45
+ }
46
+
47
+ const predicate = test.slice(start, end);
48
+
49
+ // Load external doc (load from "cache" if already loaded)
50
+ const filepath = matches[1].slice(1, -1);
51
+ const absolutePath = path.resolve(resourceDir, filepath);
52
+ const stat = fs.statSync(absolutePath);
53
+ const cacheKey = absolutePath + ':' + stat.mtimeMs + ':' + stat.size;
54
+ let externalDoc;
55
+ if (!loadedExternalDocuments[cacheKey]) {
56
+ let externalXml = null;
57
+ try {
58
+ externalXml = fs.readFileSync(path.join(resourceDir, filepath), 'utf-8').toString();
59
+ }
60
+ catch (err) {
61
+ throw new Error('No such file \'' + filepath + '\'');
62
+ }
63
+ externalDoc = new Dom().parseFromString(externalXml);
64
+ if (Object.keys(loadedExternalDocuments).length >= 32) {
65
+ delete loadedExternalDocuments[Object.keys(loadedExternalDocuments)[0]];
66
+ }
67
+ loadedExternalDocuments[cacheKey] = externalDoc;
68
+ }
69
+ else {
70
+ externalDoc = loadedExternalDocuments[cacheKey];
71
+ }
72
+
73
+ const externalXpath = test.slice(equalInd + matches[0].length, end);
74
+
75
+ // Extract namespaces
76
+ const defaultNamespaceKey = /([^(<>.\/)]+):[^(<>.\/)]+/.exec(externalXpath)[1];
77
+ const externalNamespaceMap = externalDoc.lastChild._nsMap;
78
+ const namespaceMap = {};
79
+ for (const key in externalNamespaceMap) {
80
+ if (Object.hasOwn(externalNamespaceMap, key)) {
81
+ if (key) {
82
+ namespaceMap[key] = externalNamespaceMap[key];
83
+ }
84
+ }
85
+ }
86
+ namespaceMap[defaultNamespaceKey] = externalNamespaceMap[''];
87
+
88
+ const externalSelect = xpath.useNamespaces(namespaceMap);
89
+
90
+ // Create new predicate from extract values
91
+ const values = [];
92
+ const externalResults = externalSelect(externalXpath, externalDoc);
93
+ for (let i = 0; i < externalResults.length; i++) {
94
+ values.push(externalResults[i].value);
95
+ }
96
+ const lhv = predicate.slice(0, predicate.indexOf('=document('));
97
+ let newPredicate = '(';
98
+ for (let i = 0; i < values.length; i++) {
99
+ newPredicate += lhv + '=\'' + values[i] + '\'';
100
+ if (i < values.length - 1) {
101
+ newPredicate += ' or ';
102
+ }
103
+ }
104
+ newPredicate += ')';
105
+
106
+ // Replace test
107
+ test = test.slice(0, start) + newPredicate + test.slice(end);
108
+
109
+ matches = /@[^\[\]]+=document\((\'[-_.A-Za-z0-9]+\'|\"[-_.A-Za-z0-9]+\")\)/.exec(test);
110
+ }
111
+
112
+ return test;
113
+ }
@@ -1,40 +1,34 @@
1
- const xpath = require('xpath');
2
- const Dom = require('@xmldom/xmldom').DOMParser;
3
- const _get = require('lodash.get');
4
- const checkIfFileOrPath = require('./checkIfFileOrPath');
5
- const getSchematronMap = require('./getSchematronMap');
6
- /**
7
- * @method initializeProcess Checks the validity of the supplied xml and schematron, and sets some global variables used across functions in this script.
8
- * This calls the `getSchematronMap` and assigns the value to schematronMap variable.
9
- * @param {string} xml string content of an xml file or path to an xml file
10
- * @param {string} schematron string content of a schematron file or path to a schematron file
11
- * @param {object} options object that takes parameters as seen in the `validate` method
12
- * Sets some method specific variables that will be passed to other methods using the options object
13
- * options.xmlDoc, options.schematronMap, options.resourceDir, options.xmlSnippetMaxLength, and options.xpathSelect
14
- */
15
-
16
- function initializeProcess(xml, schematron, options) {
17
- try {
18
- xml = checkIfFileOrPath(xml);
19
- schematron = checkIfFileOrPath(schematron);
20
- }
21
- catch (err) {
22
- return err;
23
- }
24
- // Load xml doc
25
- options.xmlDoc = new Dom().parseFromString(xml);
26
- // Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
27
- options.schematronMap = getSchematronMap(schematron, options);
28
- // Extract data from parsed schematron object
29
- if (!_get(options, 'resourceDir')) {
30
- options.resourceDir = '../';
31
- }
32
- if (!_get(options, 'xmlSnippetMaxLength')) {
33
- options.xmlSnippetMaxLength = 200;
34
- }
35
- // Create selector object, initialized with namespaces
36
- // Avoid using 'select' as a variable name as it is overused
37
- options.xpathSelect = xpath.useNamespaces(options.schematronMap.namespaceMap);
38
- }
39
-
40
- module.exports = initializeProcess;
1
+ const xpath = require('xpath');
2
+ const Dom = require('@xmldom/xmldom').DOMParser;
3
+ const checkIfFileOrPath = require('./checkIfFileOrPath');
4
+ const getSchematronMap = require('./getSchematronMap');
5
+ /**
6
+ * @method initializeProcess Checks the validity of the supplied xml and schematron, and sets some global variables used across functions in this script.
7
+ * This calls the `getSchematronMap` and assigns the value to schematronMap variable.
8
+ * @param {string} xml string content of an xml file or path to an xml file
9
+ * @param {string} schematron string content of a schematron file or path to a schematron file
10
+ * @param {object} options object that takes parameters as seen in the `validate` method
11
+ * Sets some method specific variables that will be passed to other methods using the options object
12
+ * options.xmlDoc, options.schematronMap, options.resourceDir, options.xmlSnippetMaxLength, and options.xpathSelect
13
+ */
14
+
15
+ function initializeProcess(xml, schematron, options) {
16
+ xml = checkIfFileOrPath(xml);
17
+ if (!options.parsedSchematronMap) schematron = checkIfFileOrPath(schematron);
18
+ // Load xml doc
19
+ options.xmlDoc = new Dom().parseFromString(xml);
20
+ // Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
21
+ options.schematronMap = getSchematronMap(schematron, options);
22
+ // Extract data from parsed schematron object
23
+ if (!options?.resourceDir) {
24
+ options.resourceDir = '../';
25
+ }
26
+ if (options.xmlSnippetMaxLength === undefined) {
27
+ options.xmlSnippetMaxLength = 200;
28
+ }
29
+ // Create selector object, initialized with namespaces
30
+ // Avoid using 'select' as a variable name as it is overused
31
+ options.xpathSelect = xpath.useNamespaces(options.schematronMap.namespaceMap);
32
+ }
33
+
34
+ module.exports = initializeProcess;
@@ -1,122 +1,122 @@
1
- // jshint node:true
2
- // jshint shadow:true
3
- module.exports = parseSchematron;
4
-
5
- const xpath = require('xpath');
6
- const _get = require('lodash.get');
7
-
8
- function parseSchematron(doc, options) {
9
- // Extract data from schematron
10
- const schematronData = extract(doc, options);
11
-
12
- return schematronData;
13
- }
14
-
15
- function extract(doc, options) {
16
- const namespaceMap = Object.create({});
17
- const patternLevelMap = Object.create({});
18
- const patternRuleMap = Object.create({});
19
- const ruleAssertionMap = Object.create({});
20
- // // Namespace mapping
21
- const namespaces = xpath.select('//*[local-name()="ns"]', doc);
22
- for (let i = 0; i < namespaces.length; i++) {
23
- namespaceMap[namespaces[i].getAttribute('prefix')] = namespaces[i].getAttribute('uri');
24
- }
25
-
26
- // // Pattern to level mapping
27
-
28
- // Find errors phases
29
- const errorPhase = xpath.select('//*[local-name()="phase" and @id="errors"]', doc);
30
-
31
- // Store error patterns
32
- if (errorPhase.length) {
33
- for (let i = 0; i < errorPhase[0].childNodes.length; i++) {
34
- if (errorPhase[0].childNodes[i].localName === 'active') {
35
- patternLevelMap[errorPhase[0].childNodes[i].getAttribute('pattern')] = 'error';
36
- }
37
- }
38
- }
39
-
40
- // Find errors phases
41
- const warningPhase = xpath.select('//*[local-name()="phase" and @id="warnings"]', doc);
42
-
43
- // Store warning patterns
44
- if (_get(options, 'includeWarnings') && warningPhase.length) {
45
- for (let i = 0; i < warningPhase[0].childNodes.length; i++) {
46
- if (warningPhase[0].childNodes[i].localName === 'active') {
47
- patternLevelMap[warningPhase[0].childNodes[i].getAttribute('pattern')] = 'warning';
48
- }
49
- }
50
- }
51
-
52
- // // Pattern to rule and rule to assertion mapping
53
-
54
- // Find patterns
55
- const patterns = xpath.select('//*[local-name()="pattern"]', doc);
56
-
57
- // Map patterns to rules
58
- for (let i = 0; i < patterns.length; i++) {
59
- const patternId = patterns[i].getAttribute('id');
60
- const defaultLevel = patternLevelMap[patternId] || 'warning';
61
- patternRuleMap[patternId] = [];
62
- const rules = xpath.select('./*[local-name()="rule"]', patterns[i]);
63
- for (let j = 0; j < rules.length; j++) {
64
- patternRuleMap[patternId].push(rules[j].getAttribute('id'));
65
- ruleAssertionMap[rules[j].getAttribute('id')] = {
66
- abstract: parseAbstract(rules[j].getAttribute('abstract')),
67
- context: parseContext(rules[j].getAttribute('context')),
68
- assertionsAndExtensions: getAssertionsAndExtensions(rules[j], defaultLevel)
69
- };
70
- }
71
- }
72
-
73
- return {
74
- namespaceMap: namespaceMap,
75
- patternRuleMap: patternRuleMap,
76
- ruleAssertionMap: ruleAssertionMap
77
- };
78
- }
79
-
80
- function getAssertionsAndExtensions(rule, defaultLevel) {
81
- const assertionsAndExtensions = [];
82
-
83
- // Find and store assertions
84
- const assertions = xpath.select('./*[local-name()="assert"]', rule);
85
- for (let i = 0; i < assertions.length; i++) {
86
- const description = assertions[i].childNodes[0] ? assertions[i].childNodes[0].data : '';
87
- let level = defaultLevel;
88
- if (description.indexOf('SHALL') !== -1 &&
89
- (description.indexOf('SHOULD') === -1 || description.indexOf('SHALL') < description.indexOf('SHOULD'))) {
90
- level = 'error';
91
- }
92
- assertionsAndExtensions.push({
93
- type: 'assertion',
94
- level: level,
95
- id: assertions[i].getAttribute('id'),
96
- test: assertions[i].getAttribute('test'),
97
- description: description
98
- });
99
- }
100
-
101
- // Find and store extensions
102
- const extensions = xpath.select('./*[local-name()="extends"]', rule);
103
- for (let i = 0; i < extensions.length; i++) {
104
- assertionsAndExtensions.push({
105
- type: 'extension',
106
- rule: extensions[i].getAttribute('rule')
107
- });
108
- }
109
-
110
- return assertionsAndExtensions;
111
- }
112
-
113
- function parseAbstract(str) {
114
- if (str === 'true' || str === 'yes') {
115
- return true;
116
- }
117
- return false;
118
- }
119
-
120
- function parseContext(str) {
121
- return str || null;
122
- }
1
+ // jshint node:true
2
+ // jshint shadow:true
3
+ module.exports = parseSchematron;
4
+
5
+ const xpath = require('xpath');
6
+
7
+ function parseSchematron(doc, options) {
8
+ // Extract data from schematron
9
+ const schematronData = extract(doc, options);
10
+
11
+ return schematronData;
12
+ }
13
+
14
+ function extract(doc, options) {
15
+ const namespaceMap = Object.create(null);
16
+ const patternLevelMap = Object.create(null);
17
+ const patternRuleMap = Object.create(null);
18
+ const ruleAssertionMap = Object.create(null);
19
+ // // Namespace mapping
20
+ const namespaces = xpath.select('//*[local-name()="ns"]', doc);
21
+ for (let i = 0; i < namespaces.length; i++) {
22
+ namespaceMap[namespaces[i].getAttribute('prefix')] = namespaces[i].getAttribute('uri');
23
+ }
24
+
25
+ // // Pattern to level mapping
26
+
27
+ // Find errors phases
28
+ const errorPhase = xpath.select('//*[local-name()="phase" and @id="errors"]', doc);
29
+
30
+ // Store error patterns
31
+ if (errorPhase.length) {
32
+ for (let i = 0; i < errorPhase[0].childNodes.length; i++) {
33
+ if (errorPhase[0].childNodes[i].localName === 'active') {
34
+ patternLevelMap[errorPhase[0].childNodes[i].getAttribute('pattern')] = 'error';
35
+ }
36
+ }
37
+ }
38
+
39
+ // Find errors phases
40
+ const warningPhase = xpath.select('//*[local-name()="phase" and @id="warnings"]', doc);
41
+
42
+ // Store warning patterns
43
+ if (options?.includeWarnings && warningPhase.length) {
44
+ for (let i = 0; i < warningPhase[0].childNodes.length; i++) {
45
+ if (warningPhase[0].childNodes[i].localName === 'active') {
46
+ patternLevelMap[warningPhase[0].childNodes[i].getAttribute('pattern')] = 'warning';
47
+ }
48
+ }
49
+ }
50
+
51
+ // // Pattern to rule and rule to assertion mapping
52
+
53
+ // Find patterns
54
+ const patterns = xpath.select('//*[local-name()="pattern"]', doc);
55
+
56
+ // Map patterns to rules
57
+ for (let i = 0; i < patterns.length; i++) {
58
+ const patternId = patterns[i].getAttribute('id') || '__pattern_' + i;
59
+ const defaultLevel = patternLevelMap[patternId] || 'warning';
60
+ patternRuleMap[patternId] = [];
61
+ const rules = xpath.select('./*[local-name()="rule"]', patterns[i]);
62
+ for (let j = 0; j < rules.length; j++) {
63
+ const ruleId = rules[j].getAttribute('id') || '__rule_' + i + '_' + j;
64
+ patternRuleMap[patternId].push(ruleId);
65
+ ruleAssertionMap[ruleId] = {
66
+ abstract: parseAbstract(rules[j].getAttribute('abstract')),
67
+ context: parseContext(rules[j].getAttribute('context')),
68
+ assertionsAndExtensions: getAssertionsAndExtensions(rules[j], defaultLevel)
69
+ };
70
+ }
71
+ }
72
+
73
+ return {
74
+ namespaceMap: namespaceMap,
75
+ patternRuleMap: patternRuleMap,
76
+ ruleAssertionMap: ruleAssertionMap
77
+ };
78
+ }
79
+
80
+ function getAssertionsAndExtensions(rule, defaultLevel) {
81
+ const assertionsAndExtensions = [];
82
+
83
+ // Find and store assertions
84
+ const assertions = xpath.select('./*[local-name()="assert"]', rule);
85
+ for (let i = 0; i < assertions.length; i++) {
86
+ const description = assertions[i].childNodes[0] ? assertions[i].childNodes[0].data : '';
87
+ let level = defaultLevel;
88
+ if (description.indexOf('SHALL') !== -1 &&
89
+ (description.indexOf('SHOULD') === -1 || description.indexOf('SHALL') < description.indexOf('SHOULD'))) {
90
+ level = 'error';
91
+ }
92
+ assertionsAndExtensions.push({
93
+ type: 'assertion',
94
+ level: level,
95
+ id: assertions[i].getAttribute('id'),
96
+ test: assertions[i].getAttribute('test'),
97
+ description: description
98
+ });
99
+ }
100
+
101
+ // Find and store extensions
102
+ const extensions = xpath.select('./*[local-name()="extends"]', rule);
103
+ for (let i = 0; i < extensions.length; i++) {
104
+ assertionsAndExtensions.push({
105
+ type: 'extension',
106
+ rule: extensions[i].getAttribute('rule')
107
+ });
108
+ }
109
+
110
+ return assertionsAndExtensions;
111
+ }
112
+
113
+ function parseAbstract(str) {
114
+ if (str === 'true' || str === 'yes') {
115
+ return true;
116
+ }
117
+ return false;
118
+ }
119
+
120
+ function parseContext(str) {
121
+ return str || null;
122
+ }
@@ -1,17 +1,17 @@
1
- const getResults = require('./getResults');
2
-
3
- /**
4
- * @method processFailedAssertions Get failed assertion object, get results and store in resultInfo
5
- * @param {array} failedAssertions Array of failed assertions
6
- * @param {object} assertionInfo Object with the assertion information
7
- * @param {object} resultInfo Object that hosts the errors, warnings and ignored arrays to store the results
8
- */
9
-
10
- function processFailedAssertions(failedAssertions, assertionInfo, resultInfo) {
11
- for (let index = 0; index < failedAssertions.length; index++) {
12
- const assertionObject = failedAssertions[index];
13
- getResults(assertionObject, assertionInfo, resultInfo);
14
- }
15
- }
16
-
17
- module.exports = processFailedAssertions;
1
+ const getResults = require('./getResults');
2
+
3
+ /**
4
+ * @method processFailedAssertions Get failed assertion object, get results and store in resultInfo
5
+ * @param {array} failedAssertions Array of failed assertions
6
+ * @param {object} assertionInfo Object with the assertion information
7
+ * @param {object} resultInfo Object that hosts the errors, warnings and ignored arrays to store the results
8
+ */
9
+
10
+ function processFailedAssertions(failedAssertions, assertionInfo, resultInfo) {
11
+ for (let index = 0; index < failedAssertions.length; index++) {
12
+ const assertionObject = failedAssertions[index];
13
+ getResults(assertionObject, assertionInfo, resultInfo);
14
+ }
15
+ }
16
+
17
+ module.exports = processFailedAssertions;
@@ -1,20 +1,20 @@
1
- const getFailedAssertions = require('./getFailedAssertions');
2
- const processFailedAssertions = require('./processFailedAssertions');
3
- /**
4
- * @method processRules Entry method to start processing schematron rules. Calls methods `getFailedAssertions` and `processFailedAssertions`
5
- * @param {Array} rules Array of ruleIds
6
- * @param {object} resultInfo Object that hosts the errors, warnings and ignored arrays to store the results
7
- * @param {object} options Passing on the options object passed to the `validate` or `validateAsync` methods
8
- */
9
-
10
- function processRules(rules, assertionInfo, resultInfo, options) {
11
- for (let index = 0; index < rules.length; index++) {
12
- const ruleId = rules[index];
13
- const failedAssertions = getFailedAssertions(ruleId, assertionInfo, options);
14
- if (failedAssertions) {
15
- processFailedAssertions(failedAssertions, assertionInfo, resultInfo);
16
- }
17
- }
18
- }
19
-
20
- module.exports = processRules;
1
+ const getFailedAssertions = require('./getFailedAssertions');
2
+ const processFailedAssertions = require('./processFailedAssertions');
3
+ /**
4
+ * @method processRules Entry method to start processing schematron rules. Calls methods `getFailedAssertions` and `processFailedAssertions`
5
+ * @param {Array} rules Array of ruleIds
6
+ * @param {object} resultInfo Object that hosts the errors, warnings and ignored arrays to store the results
7
+ * @param {object} options Passing on the options object passed to the `validate` or `validateAsync` methods
8
+ */
9
+
10
+ function processRules(rules, assertionInfo, resultInfo, options) {
11
+ for (let index = 0; index < rules.length; index++) {
12
+ const ruleId = rules[index];
13
+ const failedAssertions = getFailedAssertions(ruleId, assertionInfo, options);
14
+ if (failedAssertions) {
15
+ processFailedAssertions(failedAssertions, assertionInfo, resultInfo);
16
+ }
17
+ }
18
+ }
19
+
20
+ module.exports = processRules;