I am attempting to use Ant's XMLValidate task to validate an XML document against a DTD. The problem is not that it doesn't work, but that it works too well. My DTD contains an xref element with an "@linkend" attribute of type IDREF. Most of these reference IDs outside of the current document. Because of this, my build fails, since the parser complains that the ID that the IDREF is referencing doesn't exist. So, is there any way that I can validate my XML document against the DTD, but ignore errors of this type?
A few things I've tried: Setting the "lenient" option on XMLValidate makes the task only check the document's well-formedness, not it's validity against a DTD. The XMLValidate task in the Ant manual lists some JAXP and SAX options you can set, but none seem applicable.
Here's my code:
<target name="validate">
<echo message="Validating ${input}"/>
<xmlvalidate file="${input}" failonerror="yes"
classname="org.apache.xml.resolver.tools.ResolvingXMLReader">
<classpath refid="xslt.processor.classpath"/>
</xmlvalidate>
</target>
As you can see, I'm using ResolvingXMLReader to resolve the DTD against a catalog of public identifiers. However, I get the same behavior if I specify the DTD directly using a nested xmlcatalog element.