Towards a Theory of Document Structure