I found Astra to be surprisingly good at writing Python that generates FreeCAD documents. Arguably this says more about Astra than the ergonomy of writing FreeCAD XML, but because of Python the resulting code is very clean, because it puts anything verbose into functions. What could also work is direct OCCT from Python, haven't tried that.