This is the first version of nxvalidate written in C. Its dependencies are libxml2 and the HDF5 libraries, version 1.8.9 or better. Its purpose is to validate HDF5 files against NeXus application definitions. If you do not know what all this is, see the NeXus web site.
This repository holds two things:
- A library implementation which allows to use nxvalidate from your own software
- A proof of concept command line utility
nxvalidate is invoked like this:
nxvalidate -a appdef -l appdefdir -p path -o -b -u -d -t datafile
The minimum invocation is:
nxvalidate -l appdefdir datafile
This searches for application definitions in appdefdir and validates datafile. It expects to find the application definition to validate from from the definitions fields in NXentry or NXsubentry.
All options:
- -a appdef Validate the datafile against the application definition appdef. This option allows to override the application definition to validate against.
- -l appdefdir specifies the directory where to search for application definitions. As nxvalidate tries to load base calss definitions too, this must be given.
- -p path specifies a path in the HDF5 file to validate. This also requires an application definition to be specified with -a.
- -t Produce all output possible
- -d Produce debug output tracing what nxvalidate does
- -b Warn about additional elements in the data file found in a base class
- -u Warn about undefined additional elements in the data file
- -o Warn about optional elements which are not present in the datafile
- -e Neaten the output with more whitespace
- -r Process root group
Validation errors are always reported.
- You must include nxvalidate.h in your code
- You must link your program against the nxvalidate, xml2, hdf5 and hdf_hl libraries.
The library documentation is basically the doxygen markup of nxvalidate.h and the example use case of the command line application in nxvmain.c.
Currently you have to build nxvalidate from source.
- Download or clone the repository
- cd into it the source tree
- Create a build directory: mkdir build
- Edit CMakeLists.txt at the root level of the distribution. Due to a bug in cmake, you have to set HDF5_HL_LIBRARIES to point to the hdf5_hl library. The bug is already fixed in cmake but only very recently. Thus you may not have a fixed version of cmake.
- cd into the build diretory with cd build
- Run cmake: cmake ../
- Run make: make
- Run: make test
This should get it done. When this job has been finished, there may be binary builds as well.
In addition to cnxvalidate, you will need a copy of the NeXus base class and application definition. This is where you need to point to with the -l option. You can get a copy the NeXus definitions with the command:
git clone https://github.com/nexusformat/definitions.git
If you need to validate against a specific version of the NeXus definitions, you have to checkout the corresponding tag in the definitions repository. See the git documentation for details on how to do this.