Configuring New File Templates

You will create a set of document templates that the content authors will use as starting points for creating Simple Document Framework books and articles.

Each Document Type Association can point to a directory, usually named templates, containing the file templates. All files found here are considered templates for the respective document type. The template name is taken from the file name, and the template type is detected from the file extension.

  1. Go to the [OXYGEN_DIR]\frameworks\sdf directory and create a directory named templates.
    The directory tree of the documentation framework now is:
    oxygen
        frameworks
            sdf
                schema
                css
                templates
  2. In the templates directory create two files: a file for the book template and another one for the article template.
    The Book.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <book xmlns="http://www.oxygenxml.com/sample/documentation" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:abs="http://www.oxygenxml.com/sample/documentation/abstracts">
        <title>Book Template Title</title>
        <section>
            <title>Section Title</title>
            <abs:def/>
            <para>This content is copyrighted:</para>
            <table>
                <header>
                    <td>Company</td>
                    <td>Date</td>
                </header>
                <tr>
                    <td/>
                    <td/>
                </tr>
            </table>
        </section>
        </book>

    The Article.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <article 
        xmlns="http://www.oxygenxml.com/sample/documentation" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <title></title>
        <section>
            <title></title>
            <para></para>
            <para></para>
        </section>        
    </article>
    You can also use editor variables in the template files' content and they will be expanded when the files are opened.
    Note: You should avoid using the ${cfd},${cf},${currentFileURL}, and ${cfdu} editor variables when you save your documents in a data base.
  3. Open the Document Type configuration dialog box for the SDF framework and click the Templates tab. In the Templates directory text field, introduce the ${frameworkDir}/templates path. As you have already seen before, it is recommended that all the file references made from a Document Type Association to be relative to the ${frameworkDir} directory. Binding a Document Type Association to an absolute file (e. g.: C:\some_dir\templates) makes the association difficult to share between users.
  4. To test the templates settings, go to File > New to display the New document dialog box. The names of the two templates are prefixed with the name of the Document Type Association (SDF in this case). Selecting one of them should create a new XML file with the content specified in the template file.