In advanced document generation, one starts with a template, which is, in effect, a program in a specialized language describing how a document is computed. The template will include two kinds of construct: text element concerned with formatting, boilerplate text, and the like; and control elements concerned with computing the content of the document. The control elements will often retrieve data from databases or remote web sites, perform arbitrary computations upon them, and, in general, do nearly anything that can be done in a general-purpose programming language. Crystal reports is an example of a known application that includes document generation.
Document generation can be quite slow. Sometimes this is unavoidable and is acceptable. For example, generating a phone book of the USA is going to take a while, and that is expected. Other times, the slow performance is unacceptable, and it would be desirable to at least show the progress. For example, it is often desirable to provide a preview of a document, even a little bit of it displayed so that the user can confirm that it shows the right kind of information formatted properly.
However, it is difficult in existing technology to get a preview: a user is either processing the template, which may take a long time, or not processing and also not getting a preview. It is also desirable that the document template has the code that behaves in the same manner whether in the preview mode or final generation of a document. Otherwise, it would be much harder to develop document templates and also make the preview process much less reliable and less useful. It is desirable that the preview document be generated from the same template as the full document albeit by different processing.
A document generation system can be thought of as an interpreter for a special-purpose programming language designed for generating documents. The language will, conceptually, have some commands for producing text (including formatting controls). As a simple example, the following command inserts the specified phrase into the document:
produce “The orders in the last month are:”,
and some other commands for manipulating the sources of data for the document. The following gets a list of all the orders in the last month, stores it in a variable ORDERS, and then iterates over the list of items.
let ORDERS = database-query (all orders in the last month);for ORDER in ORDERS do produce ORDER.name;
The document that the above program would generate would look something like this: “The orders in the last month are: order-3113order-3114order-3115order-3116”. In this disclosure, examples are given in an informal and generic document generation language for the sake of clarity. In actual systems, document generation languages vary considerably, and are usually easier to type and harder to read than the informal language. They, however, generally have similar core structures.
Document templates generally have a nested structure: important elements are conceptually and structurally inside of other important elements. For example, rather than simply spilling out the names of all the orders, a document template may have a structure like this.
 let ORDERS = database-query (all orders in the last month); let INCOME = 0; produce “There were ” + ORDERS.length + “orders in the last month.They were:“; produce “<ol>”; // Start an HTML-style Ordered List for ORDER in ORDERS do  produce “<li>”; // Start an HTML-style List Item in the Ordered List  produce ORDER.name + “, price $” + ORDER.price;  produce “</li>”; // End the List Item  set INCOME = INCOME + ORDER.price produce “<ol>”; // End the Ordered List produce “And the net income was $” + INCOME;This will produce the following HTML:(full document HTML)There were 4 orders in the last month. They were:
<ol><li>order-3113, price $50</li><li>order-3114, price $150</li><li>order-3115, price $100</li><li>order-3116, price $200</li></ol>And the net income was $500which appears as follows. The <ol>...¦</ol> produce a numbered list, asfollows: (full document sample)There were 4 orders in the last month. They were:
1. order-3113, price $50
2. order-3114, price $150
3. order-3115, price $100
4. order-3116, price $200
And the net income was $500
In practice, the number of orders is likely to be far larger than 4, and the information to be presented is much more complex.
If one were to generate a preview of this document, an approximately-correct document that gives an idea of what the actual document will look like, the simplest way to get an approximate execution is to interrupt the program execution after a suitable time has elapsed. Suppose that the interruption came in the middle of the list. The produced HTML would look as follows: it is the full document HTML, chopped off in the middle.
(interrupted document HTML)
There were 4 orders in the last month. They were:
<ol><li>order-3113, price $50</li><li>order-3114, price $150The output would, at best, look something like this:(interrupted document, rendered nicely)There were 4 orders in the last month. They were:
1. order-3113, price $50
2. order-3114, price $150
Note that this document is inconsistent and incomplete. It says that there were four orders, but there are only two shown. The summary sentence is missing entirely.
In many cases, the output would be worse than what is shown above. The open tag <ol> is not matched by a closing tag </ol>, and a <li> is not matched by a closing </li>. Some existing browsers will refuse to render this, or otherwise trigger an error condition.
(interrupted document, rendered less nicely)
There were 4 orders in the last month. They were:
1. order-3113, price $50
2. order-3114, price $150
Error: Missing </li> tag in document.
Error: Missing </ol> tag in document.
This approximation is particularly pernicious. Not only is it inconsistent about the number of orders and missing the summary sentence, it has error messages about missing tags. Since those tags will actually be present in the full document, these error messages are wrong and present incorrect scenario. The natural reaction of the template-writer may be to insert new </li> and </ol> tags, however, since there are already </li> and </ol> tags in the document template, the new tags will cause the full document to be generated with malformed HTML. Such a preview is often worse than no preview at all.
USPTO Backgrounds
USPTO Backgrounds