【问题标题】:XML + Schema + Namespaces. No matching global declaration available for the validation rootXML + 架构 + 命名空间。没有可用于验证根的匹配全局声明
【发布时间】:2013-02-16 22:11:35
【问题描述】:

在使用命名空间时引用架构的正确语法是什么?

问题

使用给定架构创建 XML 文档。

错误


    .xml:9.20: Element '{http://example/buildings/1.0}old_buildings': No matching global declaration available for the validation root.
    oldbuildings.xml - invalid
    Problem

XML 文档



<?xml version="1.0" encoding="UTF-8"?>

<buildings:old_buildings xmlns:buildings="http://example/buildings/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://example/buildings/1.0 oldbuildings_schema.xsd">
    <building>
        <name>Name</name>
        <year_built era="BC">2000</year_built>
        <story>...<story>
    </building>
</buildings:old_buildings>

XSD 文档

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://示例/建筑物/1.0/"> 元素>

【问题讨论】:

    标签: xml namespaces schema


    【解决方案1】:

    在您的 xml 文件中,尝试使用

    xmlns:buildings="http://example/buildings/1.0/"

    带有 / final,就像在您的 xsd 声明中一样:xs:schema targetNamespace="http://example/buildings/1.0/"

    【讨论】:

    • @BurhanAli 因为 URI 需要在架构和 XML 文件中都匹配。其中一个 URI 中缺少“/”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多