Search code examples
node.jsxmlxsdlibxml2libxml-js

getting Error: Invalid XSD schema NODEJS using libxmljs


I am getting Error: Invalid XSD schema error while running this error. What is the actual issue, I am unable to find it.

var libxml = require("libxmljs");
var fs = require('fs');

var xsd = fs.readFileSync('D:/XML_validation/JATS-Publishing-1-3-MathML3-XSD/JATS-journalpublishing1-3-mathml3.xsd','utf8');
var xml_valid = fs.readFileSync('2100.xml','utf8');

var xsdDoc = libxml.parseXml(xsd);
var xmlDocValid = libxml.parseXml(xml_valid);

var result = xmlDocValid.validate(xsdDoc);
console.log(result);

Solution

  • With Saxon, parsing the supplied URI https://jats.nlm.nih.gov/publishing/1.3/xsd/JATS-journalpublishing1-3-mathml3.xsd directly of the web, I get errors like

    Warning at xsd:import on line 39 column 71 of JATS-journalpublishing1-3-mathml3.xsd:
       Imported schema document standard-modules/mathml3/mathml3.xsd cannot be located:
      java.io.FileNotFoundException
      (https://jats.nlm.nih.gov/publishing/1.3/xsd/standard-modules/mathml3/mathml3.xsd)
    

    That's not an answer, but it's a data point that might help you find an answer - look at the xs:include and xs:import directives.