Saving an XMLDocument Object

Figure 1. Saving an XMLDocument
save(String name, XSLTemplateInstanceKey templateKey);

Once closed, any XML document you created to write to the default internal string stream buffer can be saved to the database. This is useful if you want to print information yet keep a record of what was printed. As information in the database may change, it will not always be possible to simply print out the same form, letter, etc., and expect it to contain the same data as before. Using the XML document archive, however, you are guaranteed that the data will be identical as it represents a snapshot of the values at a particular point in time.

Each document can be saved along with the details of an associated template. This allows any print job, for example, to be rerun in the future with the same data and the same version of the template. The save method takes two input parameters and has one return value. The input parameters allow you to specify a name for this saved document. This can be any string-type information that you want. The maximum length is 100 characters. The second parameter is the template instance (version of a template) that you want to associate with this document.

The return value is the key value of the new archived document record that will be created to hold the XML data. This key value can be stored elsewhere to keep track of what documents are available. For example, if you print a letter to send to a client, you could associate this key with a diary entry recording the sending of the letter. The letter could then be reprinted at any time in the future by accessing the key stored with the diary entry.