Reorganize generation of toc.xml to avoid bootstrapping issues