-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlValidator.js
More file actions
33 lines (29 loc) · 816 Bytes
/
xmlValidator.js
File metadata and controls
33 lines (29 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const log = require("electron-log");
log.info("worker running");
const { parentPort, workerData } = require("worker_threads");
const xmllint = require("xmllint");
if (xmllint) {
log.info("xmllint defined");
}
const { xml, xsd } = workerData;
try {
let result = xmllint.validateXML({ xml, schema: xsd });
log.info("Validation Results");
if (result.errors && result.errors.length > 0) {
log.error("Validation errors occurred");
log.error(result.errors);
} else {
log.info("Validation successful");
log.info(result);
}
parentPort.postMessage({
valid: !result.errors || result.errors.length === 0,
errors: result.errors,
});
log.info("error not occuring in post messages");
} catch (error) {
parentPort.postMessage({
valid: false,
errors: [error.message],
});
}