Configuring New File Templates

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

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

Create the templates directory into the frameworks/SDF directory. The directory tree for the documentation framework is now:

oxygen
  frameworks
     sdf
       schema
       css
       templates

Now let's create in this templates directory two files, one for the book template and another 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.

Open the Document Type dialog for the SDF framework and click on the Templates tab. Enter in the Templates directory text field the value ${frameworksDir}/sdf/templates. As you already seen before, it is recommended that all the file references made from a Document Type Association to be relative to the ${frameworksDir} directory. Binding a Document Type Association to an absolute file (e.g: "C:\some_dir\templates") makes the association difficult to share between users.

To test the templates settings, press the File/New menu item to display the New dialog. The names of the two templates are prefixed with the name of the Document Type Association, in our case SDF. Selecting one of them should create a new XML file with the content specified in the template file.