简体   繁体   English

cvc-elt.1:找不到元素“xs:schema”的声明

[英]cvc-elt.1: Cannot find the declaration of element 'xs:schema'

i tried writing a simple XML document, but I am getting this error我尝试编写一个简单的 XML 文档,但出现此错误

Exception: cvc-elt.1: Cannot find the declaration of element 'xs:schema'.例外:cvc-elt.1:找不到元素“xs:schema”的声明。 false错误的

This is my XML这是我的 XML

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMALSchema">
   <xs:element name="persons">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="person">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element name="name" type="xs:string" />
                     <xs:element name="age" type="xs:integer" />
                     <xs:element name="gender" type="xs:string" />
                     <xs:element name="address">
                        <xs:sequence>
                           <xs:element name="doorno" type="xs:integer" />
                           <xs:element name="street" type="xs:string" />
                           <xs:element name="city" type="xs:string" />
                           <xs:element name="state" type="xs:string" />
                        </xs:sequence>
                     </xs:element>
                     <xs:element name="student" minOccurs="0">
                        <xs:complexType>
                           <xs:sequence>
                              <xs:element name="rollno" type="xs:integer" />
                              <xs:element name="standard" type="xs:integer" />
                              <xs:element name="section" type="xs:string" />
                           </xs:sequence>
                        </xs:complexType>
                     </xs:element>
                     <xs:element name="staff" minOccurs="0">
                        <xs:complexType>
                           <xs:sequence>
                              <xs:element name="staffid" type="xs:integer" />
                              <xs:element name="subject" type="xs:string" />
                           </xs:sequence>
                        </xs:complexType>
                     </xs:element>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>

Can you help me to give the missing declaration for <xs:schema> ?你能帮我给出<xs:schema>的缺失声明吗?

The file you have shown us is a schema - or it would be, if you corrected the namespace URI.您向我们展示的文件是一个模式 - 如果您更正了命名空间 URI,它会是一个模式。 The error message, and the form of your question, suggest that you are treating it as an XML instance document that needs to be validated.错误消息和问题的形式表明您将其视为需要验证的 XML 实例文档。

It is possible to validate a schema document (against the schema-for-schema-documents) but it is not a normal thing to do.可以验证模式文档(针对 schema-for-schema-documents),但这不是正常的事情。 Somehow this is what you are trying to do, and it's failing because the processor doesn't know where to find the schema-for-schema-documents.不知何故,这就是您正在尝试做的事情,但它失败了,因为处理器不知道在哪里可以找到 schema-for-schema-documents。

It's not clear what exactly you are doing (when you get this error) but somehow it is confusing the XML instance document with the schema to be used for validation.目前尚不清楚您到底在做什么(当您收到此错误时),但它以某种方式将 XML 实例文档与用于验证的架构混淆了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM