Configuring templates for XML inserts
When using the map editor of Publication Manager, you are modifying the XML structure of a DITA map. For example, you may want to insert a front or a back matter, or include a table of contents. You can configure the XML fragments that are to be inserted in the DITA map.
Define your templates
The following example defines a template for adding references to topics. When this fragment is selected, a <module-ref> element is inserted in your publication, and the user is prompted to fill out the href attribute. The <module-ref> element can be added either under a <part> element, a <chapter> element, a <section> element or a <subsection> element.
<template id="TPLMODREF" name="Module-reference">
<documentFragment>
<module-ref href="contentitem:REFERENCE" />
</documentFragment>
<parentnodes>
<parentnode elementname="part"/>
<parentnode elementname="chapter"/>
<parentnode elementname="section"/>
<parentnode elementname="subsection"/>
</parentnodes>
</template>
Following example defines a template for adding sections in the Publication Manager. This template can only be added under a chapter element:
<template id="TPLSECTION" name="Section">
<documentFragment>
<section>
<title>contentitem:TITLE</title>
</section>
</documentFragment>
<parentnodes>
<parentnode elementname="chapter"/>
</parentnodes>
</template>
Define your content items
Beside XML elements, added content may be required when a document fragment is inserted. Consider following examples:
- Whenever a user inserts a chapter, he must also insert the title for this chapter
- When a link is created, the DTD requires the href attribute to be specified.
To satisfy these requirements, placeholders can be defined inside the template indicating the location for this type of user input.
Placeholders you use inside the templates must be defined. The <contentitem> element is the container for storing content items.
The <contentitem> element has following attributes:
| Attributes | Required | Description 2 |
|---|---|---|
id | Yes | Unique identifier of the content item |
type | No | Indication of content item type. The only value that is allowed is text (default) |
Following example defines the content item with identifier REFERENCE.
<contentitem id=”REFERENCE” type=”text”>
<label>Reference</label>
<helptext>Reference to an information object.</helptext>
</contentitem>