首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我使用Node.js验证了xml schema的xml schema,但失败了。我也不知道原因

我使用Node.js验证了xml schema的xml schema,但失败了。我也不知道原因
EN

Stack Overflow用户
提问于 2020-08-10 11:38:29
回答 1查看 221关注 0票数 0

下面是我写的代码:

代码语言:javascript
复制
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');
    }
});

输出结果为:

架构架构格式良好

架构架构不是有效的架构

这对我来说没什么意义。

EN

回答 1

Stack Overflow用户

发布于 2020-08-10 16:22:31

为什么要忽略exception e中的信息?如果你不看错误信息,你不知道它失败的原因也就不足为奇了。

话虽如此,https://www.w3.org/2009/XMLSchema/XMLSchema.xsd的模式文档似乎是XSD1.1的模式(尽管可能不是最终的模式,因为XSD1.1推荐标准是在2012年发布的),而libXML处理器只支持XSD1.0。

(我不知道用于Node.js的XSD1.1处理器。也许有一天我们会在Saxon-JS产品中包含模式处理,但它还没有实现。)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63333798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档