简体   繁体   English

使用 Node.js 我验证了 xml 模式的 xml 模式,但它失败了。 我不知道为什么

[英]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.

相关问题 我正在使用 Node.js 和 Facebook API,我在这个函数中遇到了问题,我不知道如何解决它 - I am using Node.js and the Facebook API, I have problem in this function and I don't know how to resolve it 我正在尝试使用node.js将文件上传到AWS,但我不知道我的代码出了什么问题 - I'm try to upload file using node.js to aws but i don't know what went wrong with my code node.js 不起作用我认为这可能是安装问题或者我不知道 - node.js doesn't work i think it maybe problem of install or i don't know 不知道在使用 node.js 和 mongoose JS 创建的应用程序中将架构文件放在哪里 - don't know where to put schema files in my app which is created using node.js and mongoose JS 如果我不知道参数数量(JS,Node.js),如何编写函数 - how to write a function if I don't know number of parametrs (JS, Node.js) 如何使用Node.js知道xml文件内容的更改 - How to know the change in content of an xml file using Node.js 嘿,当使用 node.js 从 html 表单将数据插入 MySql 时,我不知道从哪里开始 - Hey I don't know where to start when inserting data into MySql from html form using node.js xml宽度模式作为node.js中的json - xml width schema as json in node.js VS Code Node.js macOS 调试不起作用 - 我什至不知道如何说明问题 - VS Code Node.js macOS debugging not working - I don't even know how to state the problem 我不知道为什么在我的项目中使用IntelliJ Idea(2016)无法识别node js中的核心模块 - I don't know why the core modules in node js are not being recognized within my project using IntelliJ Idea (2016)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM