What might be easier than generating a table to build the final document is CSS-shaped-and-aligned <div> tags.
So, when analyzing the master document, you'll be able to acquire or derive the position and dimensions of all of the frames (you'd need this for building your tables anyways), and then you could wrap each child page (after removing html,head, and body tags) in this:
<div style="position:absolute; top: ?; left: ?; width:?; height:?;">
child page content goes here
The big win here is you don't have to worry about grabbing the child documents in a set order. The absolute positioning will take care of visual ordering for you.