[英]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.