Info wanted: Cyclic reference structures, weak/strong references, Automation server issues

Hi,

Does anyone know any good references (articles/books/web-resources etc) for
how to build typical MDI Automation servers (with Delphi or otherwise), with
the object models typically used by Microsoft?

I'm thinking of something like the following:

Application has Documents
Documents contains a list of open Document(s)
Documents has Application (and Parent) property pointing back to the
Application object.
Document has Application property pointing back to the Application object
(and Parent back to Documents?).

I've found some information using the notion of strong vs. weak references
and pseudo objects, and I know it is possible to store "raw" pointers
(non-reference counted) in order to solve some situtations like this, but I
haven't found any real good info/theory for how to handle these issues in a
general way. Is it possible to design a consistent scheme which would handle
this perfectly?

Some issues which may complicate the task:

Some Documents may be HTML/XML type documents, containing Elements
recursively, which has a Parent property etc.
If someone invokes/loads the automation server via the application object,
loads an HTML document, navigates to an HREF attribute, sets the application
object to nil, only having a single explicit reference left to the Attribute
object, the Application should not close, but it should when the client
releases the reference to the Attribute. Via the Attribute, the client may
navigate up to the Element containing it, and further up to the Document and
up to the Application object again.

We would also like it to be possible to programmatically move
subelements/substructures from one document to another, and insert/edit
subelements programmatically (via Automation Controllers). Does there exist
a well known scheme/theory for how to handle this properly? I have some
vague ideas about how to do it, but since it is a very common situation, I
was hoping someone knows references of how to do this in a general way. It
doesn't seem obvious to me.

Cheers,

Jarle stabell
Digital Logikk AS