In a *real* SGML world, your document structure would be exactly
mirrored by the SGML structure. In HTML-ese, your H1 elements would nest
directly within the document, H2 elements within H1s and so on down. To
construct a top level outliner-style index you just need to pick up the
heading of the H1s, to expand one of them just look at the headings of
its children H2s, and so on. Take a look at the way DynaText functions,
for example.
To move around the document in terms of the hierarchy you just need to
maintain a tree within the browser. You must have a 'parent', 'child',
'left' and 'right' functions. To my mind it's bizarre to hard code
pointers or links for such functions into the document: they're part of the
semantics of having an SGML document in the first place. Furthermore, if
each element in an HTML document potentially had a unique identifier
then each element could be linked to independently of the rigid document
hierarchy that outliners like. That way you'd get the best of both
worlds.
This seems so obvious I must be missing something.
Lou