Installing XSD on Mac OS

This README describes installing the XSD compiler (xsd) and runtime library (libxsd) from binary packages on Mac OS. 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 Homebrew. The Xerces-C++ binary package is also provided with the XSD packages.

The following binary packages are provided for Mac OS (here <...> denotes the version and architecture information):

xsd-<...>-macosX.Y.tar.xz           -- XSD compiler
libxsd-<...>-macos.tar.xz           -- XSD runtime library
libxerces-c-<...>-macosX.Y-clangA.B -- Xerces-C++ library (optional)

Note that the XSD compiler package is statically linked and can be used on Mac OS version X.Y or later (it also usually works on earlier versions). The Xerces-C++ package is built with Apple Clang version A.B and should be usable with that or later versions (it also usually works with earlier versions).

By default all the packages assume the installation into /usr/local/ but can be relocated. For example, to install to /usr/local/:

$ sudo tar -xf xsd-<...>.tar.xz -C / --strip-components=1
$ sudo tar -xf libxsd-<...>.tar.xz -C / --strip-components=1

Or, to relocate to /opt/xsd/:

$ sudo mkdir -p /opt/xsd
$ sudo tar -xf xsd-<...>.tar.xz -C /opt/xsd --strip-components=3
$ sudo tar -xf libxsd-<...>.tar.xz -C /opt/xsd --strip-components=3

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
$ clang++ -std=c++11 -c hello.cxx
$ clang++ -std=c++11 -c driver.cxx
$ clang++ -std=c++11 -o driver driver.o hello.o -lxerces-c
$ ./driver hello.xml