Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在使用eclipse针对多个xsd文件验证xml文件时未验证包含的元素名称?_Xml_Eclipse_Xsd_Schema - Fatal编程技术网

为什么在使用eclipse针对多个xsd文件验证xml文件时未验证包含的元素名称?

为什么在使用eclipse针对多个xsd文件验证xml文件时未验证包含的元素名称?,xml,eclipse,xsd,schema,Xml,Eclipse,Xsd,Schema,我正在使用eclipse编写xml模式,我在验证方面有一个小问题 我有两个模式和一个xml文件 Main.xsd: <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/Main" xmlns:tns="http://www.example.org/Main"

我正在使用eclipse编写xml模式,我在验证方面有一个小问题

我有两个模式和一个xml文件

Main.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/Main"
    xmlns:tns="http://www.example.org/Main"
    elementFormDefault="qualified">

    <complexType name="mainType">
        <sequence>
            <any namespace="##other" processContents="lax" />
        </sequence>
    </complexType>

    <element name="main" type="tns:mainType" />
</schema

但如果我更改子元素的元素名称,则验证成功:


我还以为这次验证也会失败。这不是什么?

我想这是因为lax的定义来自XML模式定义:

lax:如果项具有唯一确定的可用声明,则 必须对该声明有效,即有效· 如果你能,如果你不能,不要担心

换句话说,因为没有可用的
元素声明,所以它是有效的

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/Sub"
    xmlns:tns="http://www.example.org/Sub"
    elementFormDefault="qualified">

    <complexType name="subType">
        <attribute name="name" type="string"
            use="required" />
    </complexType>

    <element name="sub" type="tns:subType" />
</schema>
<?xml version="1.0" encoding="UTF-8"?>
<tns:main xmlns:tns="http://www.example.org/Main"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sub="http://www.example.org/Sub"
    xsi:schemaLocation="
        http://www.example.org/Main Main.xsd 
        http://www.example.org/Sub Sub.xsd">
    <sub:sub name="test" />
</tns:main>