Question

What's the simplest way to validate XML files against the DocBook 5 schema from the command-line?

In particular, I'm talking about DocBook documents that are split up across several files and included with the <xi:include href="..."/>.

The specific use case here is finding schema violations in proposed changes in the OpenStack documentation.

If I open up files in the oXygen GUI editor, it will identify schema violations, but I'd like to be able to run these checks from the command line.

Était-ce utile?

La solution

xmllint does what I need, for example:

xmllint --relaxng http://www.docbook.org/xml/5.0/rng/docbookxi.rng --noout ~/openstack-manuals/doc/src/docbkx/openstack-compute-admin/bk-compute-adminguide.xml

This outputs a string that indicates whether validation was successful:

/Users/lorin/openstack-manuals/doc/src/docbkx/openstack-compute-admin/bk-compute-adminguide.xml validates

Autres conseils

This sounds almost like a trick question: if you want to validate documents from the command line, you will want to acquire a schema validator for the schema language you have in mind with a command-line interface, no? So I guess you are asking which validators have a command-line interface?

Several XSD validators have command-line interfaces; in alphabetical order, the ones that come first to my mind are: MSV (multi-schema validator), Saxon-EE, Xerces C, and Xerces J. There are also partial XSD implementations in xmllint (the command-line interface to libxml) and xsv. I believe that it's also possible to run at least one of Microsoft's XSD implementations from the command line, but as you mention OS X in the heading I assume that's not where you want to go.

RelaxNG validators include Jing, xmllint, and msv; all have command-line interfaces.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top