Document templates are files that contain additional information about classes of documents. If you work with a certain DTD, for example the DocBook DTD, and create and edit DocBook documents, there will be a template that is used by epcEdit for your DocBook documents. If you work with a second DTD, for example the TEI DTD, another template will be used by epcEdit for your TEI documents.
Document templates are used by epcEdit for two purposes:
Templates contain information for creating new documents. For example, if you want to create a new DocBook document, you will tell epcEdit to use your DocBook template for creating a new document. If you want to create a new TEI document, you will tell epcEdit to use your TEI template.
When epcEdit creates the new document, it will apply the information from the template and initialize the new document according to the settings from the template.
SGML and XML documents do not carry layout information; they focus on abstract markup and leave the appearance of the document to specialized layout instructions that accompany the document. Since epcEdit provides layout formatting capabilities, the information about the document layout has to be stored somewhere outside of the document.
Templates store the style sheet information for documents that match the template. If you decide that a chapter title of a DocBook document should be displayed in a 24 point Helvetica bold font, this information will be recorded in your DocBook template.
When you open an existing document, epcEdit will select the matching template and apply the style sheet information from that template to your document.
The benefit of this approach is that the required information has to be provided only once: After a template has been defined, it can be used to create any number of new documents for the given document type just by selecting the template from the list of available templates.
A template is not required to open an existing document. If epcEdit can not find a matching template for your document, it will use default style sheet settings for displaying the document. However, if you add style sheet settings for a document that was opened without a template, epcEdit will offer to create a new template for this document class when the document is closed.
When a new document is created, you choose a template for the new document from the list of existing templates. Before the new document is created, epcEdit will read the template file and extract the following information:
An XML declaration if the template is for an XML document. This XML declaration can contain the specification for an encoding for the new document.
The name of the document element, i.e. the element that will enclose the rest of the document.
The public and system identifiers for the DTD if the template is for a valid XML document or for an SGML document.
Any additional declarations that should be placed in the document prolog.
This information is combined into the prolog for the new document. If the document is a valid XML or SGML document, epcEdit will load the DTD for the document. If the document is a wellformed XML document, epcEdit will initialize an empty DTD that contains only the name of the document element.