check.js
536 Bytes
const xsd = require('libxml-xsd');
const fs = require('fs');
const xsdFile = fs.readFileSync('./apps/controllers/seo/xm.xsd').toString();
for (let i = 1; i <= 78; i++) {
const xml = `./public/dist/goods-xml/goods-${i}.xml`;
const xmlFile = fs.readFileSync(xml).toString();
const schema = xsd.parse(xsdFile);
const validationErrors = schema.validate(xmlFile);
console.log(`check => start: ${i} `);
validationErrors && validationErrors.forEach(verr => {
console.log(i, verr.line, verr.str1);
});
}