Search code examples
macosxsddocbook

Validate against DocBook schema in OS X on the command-line


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.


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