Installing XSD on Debian and alike

This README describes installing the XSD compiler (xsd) and runtime library (libxsd) from binary packages on Debian and alike (Ubuntu, etc). Note that the runtime library is header-only.

Besides the runtime library, the generated code also depends on the underlying XML parser which can be Xerces-C++ for the C++/Tree mapping and Xerces-C++ or Expat for the C++/Parser mapping. Both of these XML parsers are available from the distribution's official package repository and you need to install one or the other explicitly (the libxsd package does not have a dependency on either).

The distribution's package for Xerces-C++ is called libxerces-c-dev while for Expat – libexpat1-dev.

On Ubuntu, the Xerces-C++ package is available in the universe section of the official repository. If you do not wish to have this section enabled, you can alternatively use the Xerces-C++ package provided with the XSD packages for Ubuntu.

The following binary packages are provided for Debian and alike (here <...> denotes the version, distribution, and architecture information):

xsd_<...>.deb             -- XSD compiler
libxsd-dev_<...>.deb      -- XSD runtime development files
xsd-dbgsym_<...>.deb      -- XSD compiler debug info (optional)

libxerces-c_<...>.deb     -- Xerces-C++ runtime files (Ubuntu-only)
libxerces-c-dev_<...>.deb -- Xerces-C++ development files (Ubuntu-only)

For example, to install XSD with Xerces-C++, run:

$ sudo apt-get update
$ sudo apt-get install ./xsd_<...>.deb \
                       ./libxsd-dev_<...>.deb \
                       libxerces-c-dev

Note that the .deb files must include a directory separator (/) in order for apt to recognize them as files rather than as package names.

To test the installation you can try to build and run an example, for example cxx/tree/hello/ from the xsd-examples source package (see examples README for details):

$ xsd cxx-tree hello.xsd
$ c++ -std=c++11 -c hello.cxx
$ c++ -std=c++11 -c driver.cxx
$ c++ -std=c++11 -o driver driver.o hello.o -lxerces-c
$ ./driver hello.xml