简体   繁体   English

XSD验证错误:“ cvc-elt.1:找不到元素'xs:schema'的声明”

[英]Error with XSD validation: “cvc-elt.1: Cannot find the declaration of element 'xs:schema'”

I am trying to use the Maven XML plugin to validate my xml against a schema but I keep having an error saying: 我正在尝试使用Maven XML插件针对模式验证我的xml,但是我一直遇到错误:

cvc-elt.1: Cannot find the declaration of element 'xs:schema'. cvc-elt.1:找不到元素'xs:schema'的声明。

I guess it has to deal with my namespaces declaration, so here they are: 我想它必须处理我的名称空间声明,因此它们是:

In my XSD: 在我的XSD中:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns="http://www.myurl.com/schemas" 
  targetNamespace="http://www.myurl.com/schemas" 
  elementFormDefault="qualified" version="1.0">

In my XML: 在我的XML中:

<myTag xmlns="http://www.myurl.com/schemas">

What is wrong with those declarations? 这些声明有什么问题? What do I need to modify? 我需要修改什么?

Thanks for your help. 谢谢你的帮助。

In your pom.xml 在你的pom.xml中

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xml-maven-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>validate</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <catalogs>
          <catalog>src/main/resources/xsd/catalog.xml</catalog>
      </catalogs>
      <validationSets>
        <validationSet>
          <dir>src/main/resources/xsd</dir>
          <systemId>src/main/resources/xml/mytag.xml</systemId>
        </validationSet>
      </validationSets>
    </configuration>
  </plugin>

and in your catalog file src/main/resources/xsd/catalog.xml 并在目录文件src / main / resources / xsd / catalog.xml中

<catalog>
    <system systemId="http://www.w3.org/2001/XMLSchema" uri="http://www.w3.org/2001/XMLSchema.xsd"/>
</catalog>

For more information on catalog configuration see Maven Plugin Catalog 有关目录配置的更多信息,请参见Maven插件目录。

暂无
暂无

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

相关问题 cvc-elt.1:找不到元素“xs:schema”的声明 - cvc-elt.1: Cannot find the declaration of element 'xs:schema' 使用cvc-elt.1进行xsd验证失败:无法找到元素的声明 - xsd validation fails with cvc-elt.1: Cannot find the declaration of element Eclipse中的错误“ cvc-elt.1:找不到元素&#39;xs:schema&#39;的声明。” - Error “cvc-elt.1: Cannot find the declaration of element 'xs:schema'.” in Eclipse 如何修复错误:cvc-elt.1:找不到没有命名空间的元素“xsd:schema”的声明? - How to fix the error: cvc-elt.1: Cannot find the declaration of element 'xsd:schema' without namespaces? CXF的JAXB模式验证错误-发生JAXBException:cvc-elt.1:找不到元素的声明 - JAXB schema validation error with CXF - JAXBException occurred : cvc-elt.1: Cannot find the declaration of element XML,XSD,cvc-elt.1:找不到元素的声明 - XML, XSD, cvc-elt.1: Cannot find the declaration of element 针对XSD的XML验证:cvc-elt.1:找不到元素&#39;xxx&#39;的声明 - XML validation against XSD: cvc-elt.1: Cannot find the declaration of element 'xxx' 无法针对xsd验证xml。 错误“ cvc-elt.1:找不到元素&#39;systems&#39;的声明” - Cannot validate xml against a xsd. Error “cvc-elt.1: Cannot find the declaration of element 'systems'” cvc-elt.1:找不到元素的声明 - cvc-elt.1: Cannot find the declaration of element 错误:cvc-elt.1:找不到元素“beans”的声明 - Error: cvc-elt.1: Cannot find the declaration of element 'beans'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM