Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate XML against DTD using Saxon from command line

I have a library Saxon9ee.jar and I want to validate XML file against DTD schema located in external file (not inside XML) using Saxon9ee with command line interface. I found out how to validate XML against XSD schema:

java -cp saxon9ee.jar com.saxonica.Validate -xsd:<XSD_file> -s:<XML_file> -xsdversion:1.1

But how can I do the same with DTD schema file?

like image 738
sunigos Avatar asked Sep 20 '25 04:09

sunigos


1 Answers

Validating against a DTD doesn't really involve Saxon at all, it's all done in the XML parser. But oddly, the Xerces parser is rather poor in terms of command line interfaces, so invoking it via Saxon is probably the most convenient way of doing it. Run the simplest possible query, with DTD validation enabled:

java net.sf.saxon.Query -qs:. -s:source.xml -dtd:on
like image 149
Michael Kay Avatar answered Sep 22 '25 08:09

Michael Kay