[英]Using Node.js I validated the xml schema for xml schemas and it failed. I don't know why
Here is the code I wrote:这是我写的代码:
const request = require('request');
const libXMLJS = require("libxmljs");
request.get('https://www.w3.org/2009/XMLSchema/XMLSchema.xsd', function (error, response, body) {
if (!error && response.statusCode === 200) {
// is it well-formed?
try {
libXMLJS.parseXml(body);
} catch(e) {
console.log('schema schema not well-formed');
return;
}
console.log('schema schema well-formed');
// Is the schema schema a valid schema?
const schemaSchema = libXMLJS.parseXml(body);
try {
schemaSchema.validate(schemaSchema)
} catch(e) {
console.log('schema schema not valid schema');
return;
}
console.log('schema schema valid schema');
}
});
The output was: output 是:
schema schema well-formed架构良好的架构
schema schema not valid schema架构架构无效架构
This doesn't make sense to me.这对我来说没有意义。
Why are you ignoring the information in the exception e
?您为什么忽略异常
e
中的信息? It's not surprising you don't know why it failed if you don't look at the error information.如果您不查看错误信息,您不知道为什么失败也就不足为奇了。
Having said that, the schema document at https://www.w3.org/2009/XMLSchema/XMLSchema.xsd appears to be a schema for XSD 1.1 (though probably not the final one, since the XSD 1.1 recommendation was published in 2012) and the libXML processor only supports XSD 1.0. Having said that, the schema document at https://www.w3.org/2009/XMLSchema/XMLSchema.xsd appears to be a schema for XSD 1.1 (though probably not the final one, since the XSD 1.1 recommendation was published in 2012 ) 并且 libXML 处理器仅支持 XSD 1.0。
(I'm not aware of an XSD 1.1 processor for Node.js. One day perhaps we'll include schema processing in the Saxon-JS product, but it's not there yet.) (我不知道 Node.js 的 XSD 1.1 处理器。也许有一天我们会在 Saxon-JS 产品中包含模式处理,但它还没有。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.