cvc-elt.1.a:找不到元素'...'的声明

时间:2013-06-12 06:24:46

标签: xml xsd xsd-validation

我的XSD如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="AppRegisterConfig">
    <xs:sequence>
        <xs:element name="restServiceUrl" type="xs:string" />
        <xs:element name="timeout" type="xs:int" />
        <xs:element name="attempts" type="xs:int" />
    </xs:sequence>
</xs:complexType>

我的XML如下:

<?xml version="1.0" encoding="UTF-8"?>
<appregister-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:noNamespaceSchemaLocation="appregister-config.xsd">

  <restServiceUrl><url>url 1</url></restServiceUrl>
  <timeout>15000</timeout>
  <attempts>5</attempts>  
</appregister-config>  

知道我可能错过了什么吗?

1 个答案:

答案 0 :(得分:1)

您还没有说过如何调用验证,但默认情况下,架构处理器会在架构中查找与源文档中最外层元素名称匹配的元素声明,如果找不到它,则会告诉你的。这就是这里发生的事情。

我希望看到

<xs:element name="appregister-config" type="AppRegisterConfig"/>
在您的架构中

相关问题