by Tom Radcliffe
Copyright: Tom Radcliffe
For those outside the structured text (SGML/XML) community, the idea of structured text is to treat documents as nested tree structures--HTML is an example of this, where the <HTML> element contains the <BODY> which contains paragraphs and lists and so on. Structured text processors typically build a tree of objects as the applciation parses the document, to create a programmatic representation of the text. The the application then typically lets the user manipulate this representation of the document, so "the document is the application."
Narrative programming turns this idea around: rather than thinking about building an application to work on documents, think instead of creating a document to build applications. The "document" in this case is the XML Document Type Definition (DTD), which specifies the range of allowed forms a conforming document can have. Once we know the allowed structure of the documents it is supposed to work on, we should be able to automatically generate an application that will only represent conforming documents. The Narrative Programming Framework, which is partially described in the book, is an early attempt to realize this possibility.
The book is incomplete, and the framework code is not publicly available, because the framework is now used inhouse commercially for application development, particularly for rapid prototyping. As I no longer own the code, I'm not free to distribute it. The book is partly about framework design, and partly about the specific design choices I made. As such, it may be of interest to people who are trying to do something similar--the NPF falls well within the compass of the growing trend in "Generative Programming", and I'm pretty pleased to have been involved in GP almost three years before I'd even heard of it.
Automatically generated code is an idea whose time has come, and the overlap between document structure and application structures is ripe for exploitation by code generators because we have a standard language for describing document structure: XML. The NPF is one early attempt to exploit that overlap, and while I don't expect anyone will agree with all my design decisions--I don't agree with all my design choices--I hope this document will be of value to those who are exploring this route.