![](/img/trans.png)
[英]I am using Node.js and the Facebook API, I have problem in this function and I don't know how to resolve it
[英]Using Node.js I validated the xml schema for xml schemas and it failed. I don't know why
这是我写的代码:
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');
}
});
output 是:
架构良好的架构
架构架构无效架构
这对我来说没有意义。
您为什么忽略异常e
中的信息? 如果您不查看错误信息,您不知道为什么失败也就不足为奇了。
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。
(我不知道 Node.js 的 XSD 1.1 处理器。也许有一天我们会在 Saxon-JS 产品中包含模式处理,但它还没有。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.