This causes problems with paths to input data files
and forces each example to use complicated logic to calculate paths.

True, particularly in Restrainer's case where you have paths embedded in your XML files - you can't use get_example_path() there.
Can't you use relative paths there? eg the .xml file contains "./foo.dat" (or just "foo.dat") which should search for the data file relative to the input xml. Otherwise, either you can't relocate you setup or have to always run it from the same directory relative to the .xml file, both of which would be very annoying. Or perhaps I'm confused.



Would it be a good idea to
modify the build process to run examples from their respective
directories? This way all examples can use the relative paths and if a
user wishes to run an example, he/she can just cd to the example
directory and run it directly from there.

Yes, I agree - for running examples during the build, it should be straightforward enough to have the build system cd into build/doc/examples to run the example. That also ensures that any outputs generated by the example don't end up littering the source tree.
The directory containing the examples isn't necessarily writable (say once they are installed), so we have to be careful about any files they write. I think it is reasonable to insist that the working directory is writeable to produce output, but we could also have the samples write to a tmp dir.