Over 10 years ago I wrote a tool to transform Open Office files (with proper styles applied) to Docbook using XSLT and Schematron. It was fun to do. Now all these techs seem to have almost completely disappeared, which is kind of sad. It was fun.
Apache FOP / Batik is okay for generating nice looking PDFs, but its SVG rasterization is much worse than that of Chrome's PDF renderer (Skia).
As I didn't get the memo about XML being dead, I'm still using Docbook and XSLT/XInclude to structure and filter content written in markdown/rst.
But I will be switching over from XSL-FO to CSS paged media for layout as soon as Chrome supports bookmarks in PDF output, or either WeasyPrint or wkhtmltopdf improve their CSS3 column support.