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

前端 未结 1 1798
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 22:07

I am trying to use the Maven XML plugin to validate my xml against a schema but I keep having an error saying:

cvc-elt.1: Cannot find the declaration of e

相关标签:
1条回答
  • 2021-01-26 22:21

    In your 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

    <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

    0 讨论(0)
提交回复
热议问题