mojohaus / xml-maven-plugin

XML Maven Plugin
https://www.mojohaus.org/xml-maven-plugin/
Apache License 2.0
23 stars 21 forks source link

Resolve DTD for validation #51

Open 1stone opened 6 years ago

1stone commented 6 years ago

I'm trying to validate a bunch of XML files, organized in a multi-directory filesystem structure, against a DTD.

From what I understand from #46 and #47 that should still be possible with 1.0.2 if a DOCTYPE decl is present on the XML files. So, given this definition in the XML files

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE acme PUBLIC "acme.dtd" "acme.dtd">
...

I would like to validate against that acme.dtd which is located in the root of the validationSet directory. But unfortunately, the validation fails with While parsing /.../vroot/path/to/this.xml: /.../vroot/path/to/acme.dtd (No such file or directory), with vroot being the directory in the validationSet and where acme.dtd is located.

I tried to "register" the DTD file via a catalog setting, but to no avail. Is there any way to configure the plugin in a way, that all XML files with DOCTYPE acme will be validated against the DTD file in the vroot?

This is the current plugin config for reference:

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>xml-maven-plugin</artifactId>
          <version>1.0.2</version>
          <configuration>
            <validationSets>
              <validationSet>
                <dir>${project.build.xml.directory}</dir>
                <validating>true</validating>
              </validationSet>
            </validationSets>
            <catalogs>
              <catalog>${project.build.xml.directory}/acme.dtd</catalog>
            </catalogs>
            <catalogHandling>strict</catalogHandling>
          </configuration>
        </plugin>
rosslamont commented 6 years ago

Hi there,

Have a read of catalog files. Your configuration shows a catalog called acme.dtd which is almost certainly not a catalog file. A catalog is a defined standard which provides a way for the plugin to map where a local copy of a remote schema or dtd can be found.

Out of interest, do you get an error message with the configuration shown above? Would you be able to post it in a comment - we try to clean up awkward error messages.

Cheers Ross