XML technologies / DITA / Creating and organizing topics / Generic topic

(Excerpt from “DITA – Der neue Standard für Technische Dokumentation” by Johannes Hentrich)

The generic topic is the archetype of all other DITA topic types. Task, reference and concept specialize the generic topic, and the glossary type further specializes concept.

Numerous elements are defined for a generic topic that can also be used in specialized topics of the task, reference, concept and glossary types.

The following first explains how to build a generic topic. Later sections introduce elements usable in all topic types, namely elements for:

Basic structure of a generic topic

A generic topic’s elements are defined in the module file topic.mod, referenced in tasd.dtd.

A generic topic has the following basic structure:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "../dtd/topic.dtd">
<topic id="topic_nr_1">
    <title></title>
    <body>
        <p>Der Topictyp „Konzept“ enthält...</p>
    </body>
</topic>

Since a DITA topic is stored in an XML file, it begins with an XML declaration, which every XML file must contain.

Next, the DOCTYPE declaration references the public identifier (public identifier) for the topic.dtd DTD. The topic.dtd-file references the topic.mod module file defining the generic topic’s elements. The toolkit’s default XML catalog file maps the public identifier to a directory path containing the topic.dtd DTD and the other DITA DTDs on the local disk. For more about XML catalog files, see XML catalogs.

A generic topic is identified by the root element <topic>, also defined in the DOCTYPE declaration. The root contains all other generic topic elements.

The root element <topic> must have a value for the id attribute that uniquely identifies the generic topic.

When creating and managing large topic collections, a suitable policy must ensure that the id attributes really are unique across the collection. Content management systems generally generate unique id attribute values automatically. XML editors such as XMetal can also automatically generate unique id attribute values.

The <title> element assigns the topic a title, displayed for example in an online help table of contents. Its <title> element may also be empty. This can be useful, for example, when storing a book’s copyright notice in a topic without a heading.

A generic topic’s actual content is in the <body> element, much as in HTML documents.

The <p> element inserts paragraphs, as in HTML. The next section introduces further elements for recording and structuring information in topics.

Saving a DITA topic with a DITA-aware XML editor often appends the extension .dita automatically to the filename, for example generisches_topic.dita. This may be undesirable because the operating system often has no application, that is, XML editor, associated with the .dita extension. Double-clicking a filename with the extension .dita then opens a program-selection dialog instead of launching an XML editor automatically.

Since version 1.3, the DITA Open Toolkit can process the extensions .dita and .xml in the same way without configuration.

 

Titles and content information

The <title> element assigns a title to a topic. Output media often use it for navigation, for example as a link to the topic in a table of contents. However, the title may be too long or awkward for online help navigation. DITA therefore allows an additional navigation title and search title alongside the normal title.

The <navtitle> element assigns a navigation title. HTML pages, for example, often use one because the actual page title is too long for website navigation.

The <searchtitle> element specifies what appears in a search results list.

The <navtitle> element and the <searchtitle> element are defined in the <titlealts> element.

<title>So erstellen Sie Topics</title>
<titlealts>
    <navtitle>Topics erstellen</navtitle>
    <searchtitle>Informationen zum Erstellen von generischen Topics<searchtitle>
</titlealts>

The <abstract> element and the <shortdesc> element control what is displayed in a link preview in the output medium.

If a topic’s first section should not be used as the preview, for example because it contains a table, put the preview content in the <abstract> element. Within the <abstract> element, content can be marked using the <p> element.

If the first section’s content should be used for the preview instead, put it in the <shortdesc> element. The <shortdesc> element is then inside the <abstract> element. The content of the <shortdesc> element is treated like content from the <body> element. The following example uses the <abstract> and <shortdesc> elements, placed after the <title> element and before the <body> element.

<topic>
    <title>So erstellen Sie Topics</title>
    <abstract>Informationen zum Erstellen von Topics
        <shortdesc>Die Grundstruktur eines Topics...</shortdesc>
    </abstract>
    <body>
        <p>.....</p>
    </body>
</topic>

Block elements

Block elements structure information within a topic. Many block elements or their names are familiar from HTML, such as <p> (paragraph), <ol> (ordered list), <ul> (unordered list), <li> (list item), <table> and so on.

Available block elements depend on the topic type. For example, the <section> element is not allowed in the task topic type. Concept has the largest selection of available elements.

The following briefly introduces the most frequently used block elements:

  • <ul>, <ol> and <li>: these elements define lists. As in HTML, the <ul> element defines an unordered list using bullets or similar markers. In contrast, a list defined with the <ol> element numbers its entries. Both unordered and ordered lists mark entries with the <li> element.

<ul>
    <li>500 g Mehl</li>
    <li>250 g Butter</li>
    <li>250 ml Milch</li>
    <li>4 Eier</li>
</ul>

  • <dl>, <dlentry>, <dt> and <dd>: these elements create a definition list, used for example in glossaries. Each term, defined by the <dt> element, has an explanation in the <dd> element. Both are grouped in the <dlentry> element.

<dl>
    <dlentry>
        <dt>SGML</dt>
        <dd>Standard General Markup Language</dd>
        <dt>XML</dt>
        <dd>eXtensible Markup Language</dd>
    </dlentry>
</dl>

A definition list can also have a heading, using the elements <dlhead>, <dthd>, <ddhd>.

<dl>
    <dlhead>
        <dthead>Abkürzung></dthead>
        <ddhd>Erklärung</ddhd>
    </dlhead>
    <dlentry>
        <dt>SGML</dt>
        <dd>Standard General Markup Language
        </dd>
        <dt>XML</dt>
        <dd>eXtensible Markup Language</dd>
    </dlentry>
</dl>

  • <table>: the <table> element and subelements such as <tgroup>, <colspec>, <thead>, <tbody>, <row> and <entry> define tables according to the CALS table model. Creating a table with the <table> element resembles HTML but differs in important ways. A <tgroup> element specifies the number of columns. A <table> element can contain several <tgroup> elements. Within the contained <tbody> element, rows and columns are defined using the <row> and <entry> elements. The following example shows the table structure:

<table>
    <thead>
        <row>
            <entry>1.Spalte</entry>
            <entry>2.Spalte</entry>
        </row>
    </thead>
    <tgroup cols="2">
        <tbody>
            <row>
                <entry>1.Spalte, 1.Zeile</entry>
                <entry>2.Spalte, 1.Zeile</entry>
            </row>
            <row>
                <entry>1.Spalte, 2.Zeile</entry>
                <entry>2.Spalte, 2.Zeile</entry>
            </row>
        </tbody>
    </tgroup>
</table>

The <thead> element defines a table header. It contains one row, defined by the <row> element, and two column entries, defined by the <entry> element.

The cols attribute in the <tgroup> element defines the number of columns. Individual table cell entries are defined inside the <tbody> element using the <row> and <entry> elements.

  • <simpletable>: simpler tables, more like those familiar from HTML, can be created with the <simpletable> element. Inside the <simpletable> element, only the following elements are allowed: <sthead>, <strow> and <stentry>. As a simple table, the previous example looks as follows:

<simpletable>
    <sthead>
        <stentry>1.Spalte</stentry>
        <stentry>2.Spalte</stentry>
    </sthead>
    <strow>
        <stentry>1.Spalte, 1.Zeile</stentry>
        <stentry>2.Spalte, 1.Zeile</stentry>
    </strow>
    <strow>
        <stentry>1.Spalte, 2.Zeile</stentry>
        <stentry>2.Spalte, 2.Zeile</stentry>
    </strow>
</simpletable>

  • <section>: the <section> element further subdivides content within a topic. A <title> element assigns headings to sections, as shown in the following generic topic:

<topic id="topic_nr_2">
    <title>Testbericht</title>
    <body>
        <section>
            <title>Testszenario</title>
            <p>Dem Test wurden folgende Produkte unterzogen...</p>
        </section>
        <section>
            <title>Fazit</title>
            <p>Als Testsieger wurde folgendes Produkt ermittelt: ...</p>
        </section>
    </body>
</topic>

  • <example>: the <example> element marks examples in topics. As with the <section> element, each example can be given a heading using the <title> element.

<topic id="topic_nr_2">
    <title>Beispiel</title>
    <body>
        <example>
            <title>Listen</title>
            <p>Das folgende Beispiel zeigt, wie Listen...</p>
        </example>
        <example>
            <title>Einfache Tabellen</title>
            <p>Das folgende Beispiel zeigt, wie einfache Tabellen...</p>
        </example>
    </body>
</topic>

 

Metadata

Block elements capture information displayed to users in output media, while metadata captures data about the topic. Metadata is usually invisible in the output. It can, for example, add author information, classify the topic or provide enhanced access to it.

Metadata is recorded in the <prolog> element. The following introduces the many elements inside the <prolog> element used to record metadata.

  • <author>: identifies the topic’s author. The type attribute specifies the author’s status: primary author (creator) or contributor to the topic (contributor).

<prolog>
    <author type="creator">Johannes Hentrich</author>
</prolog>

  • <audience>: the topic’s target audience is recorded in the <audience> element. The type attribute specifies the intended audience with values such as user, purchaser or executive. The job attribute also defines a kind of task description, with values such as installing, customzing, maintaining or migrating. The reader’s required level of expertise is specified through the experiencelevel attribute. Within the <prolog> element, the <audience> element may appear multiple times if several audiences must be defined. The <audience> element is used inside the <metadata> element.

<prolog>
    <metadata>
        <audience type="user" job="using" experiencelevel="general" />
    </metadata>
</prolog>

  • <copyright>: copyright information is recorded in the <copyright> element. The type attribute specifies the copyright holder’s status (primary or secondary). Within the <copyright> element, the <copyrholder> element gives the copyright holder’s name, and the <copyryear> element uses the year attribute to specify the copyright year.

<prolog>
    <copyright>
        <copyrholder type="primary">Johannes Hentrich</copyrholder>
        <copyryear year="2008"/>
    </copyright>
</prolog>

  • <critdates>: the creation date and dates important to the document’s lifecycle can be entered in the <critdates> element. The <created> element uses the date attribute to specify when the topic was created, and the golive attribute to specify when it was first published. The <revised> element records its last revision, using the modified attribute.

<prolog>
    <critdates>
        <created date="2008-08-06"></created>
        <revised modified="2008-08-31"></revised>
    </critdates>
</prolog>

  • <keywords>: keywords searchable in search engines or retrieval systems can be assigned in the <keywords> element. Each keyword is recorded in a <keyword> element. The <keywords> element is used inside the <metadata> element.

<prolog>
    <metadata>
        <keywords>
            <keyword>DITA</keyword>
            <keyword>Meta-Daten</keyword>
            <keyword>Verschlagwortung</keyword>
        </keywords>
    </metadata>
</prolog>

  • <metadata>: the <metadata> element is a container for metadata elements such as <audience>, <keywords> or <prodinfo>.

  • <permissions>: the <permissions> element specifies who can access the topic. Access may be controlled by filtering the relevant topics during production or by external systems evaluating the <permissions> element. The view attribute defines access classes using the values internal, classified, all and entitled.

<prolog>
    <permissions view="classified"/>
</prolog>

  • <prodinfo>: information about the product described in the topic can be stored using the <prodinfo> element. The <prodinfo> element contains the <prodname> element with the product name, the <vrmlist> element with version information, the <prodnum> element with the product number, and the <platform> element with information about the product’s hardware or software.

<prolog>
    <metadata>
        <prodinfo>
            <prodname>Task Modeler</prodname>
            <vrmlist>
                <vrm release="6"/>
            </vrmlist>
            <prodnum>6-34-5</prodnum>
            <platform>Windows</platform>
        </prodinfo>
    </metadata>
</prolog>

Graphics and multimedia objects

DITA documents can include graphics and multimedia objects just as HTML does. Images, Flash animations, videos and so on are referenced in the DITA XML file.

Images use the <image> element. The href attribute references the image.

 <image href="../images/pinguin.gif"/> 

Several attributes are defined for the <image> element. The alt attribute familiar from HTML is replaced in DITA by an <alt> element describing the image.

<image href="../images/pinguin.gif">
    <alt>Linux-Logo</alt>
</image>

Attributes of the <image> element include:

  • height: specifies the image height.

  • width: specifies the image width.

  • align: specifies horizontal alignment. Possible values are right, left, center and current.

  • scale: specifies image scaling. If no height and width are given, the scale attribute specifies a percentage scaling factor. A value of 100 outputs the image at its original size.

  • placement: determines how the image flows: whether it is placed within the text or text is placed around it.

Multimedia objects use the <object> element as in HTML. The following example uses the <object> element to embed a Flash animation.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" data="eim.swf" height="400" width="500" id="eim">
    <desc>Some great, glorious info</desc>
    <param name="movie" value="eim.swf"/>
    <param name="quality" value="high"/>
    <param name="bgcolor" value="#FFFFFF"/>
    <param name="pluginspace" value="http://www.macromedia.com/go/getflashplayer"/>
</object>

The <object> element has numerous attributes:

  • classid: references the multimedia object’s implementation.

  • codebase: gives the Internet address for downloading the plugin if it is not installed on the user’s system.

  • data: gives the path to the multimedia object.

  • height: specifies the height of the object’s display area.

  • width: specifies the width of the object’s display area.

  • id: assigns a unique ID to the multimedia object.

The following elements are used inside the <object> element:

  • <param>: contains parameters passed to the multimedia object.

  • <desc>: contains a description of the multimedia object and corresponds to the <alt> element for images.

Index entries

Index entries are marked using the <indexterm> element. Processing DITA XML files collects all <indexterm> entries and automatically combines them into an index, much as in word processors. Entries are sorted alphabetically, and identical entries from different topics are merged into one.

Index entry placement is barely restricted. Almost all elements inside the <body> element or its specializations may contain index entries.

The following example defines an index entry within a <p> element:

<p>Studiert man Charles Darwins (1809 – 1882) <indexterm>Charles Darwin</indexterm> epochales Werk „Über die Entstehung der Arten durch natürliche Zuchtwahl“ wird man viel über Vögel und Schildkröten <indexterm>Schildkröten</indexterm> erfahren können, jedoch so gut wie gar nichts – wen wundert’s – über Technische Dokumentation.</p>

The <indexterm> element also creates nested index entries. Define further <indexterm> elements within an <indexterm> element. The following shows simple nesting:

<indexterm>DITA
    <indexterm>Spezialisierung<indexterm>
</indexterm>

Since DITA 1.1, references to other index entries are also possible using the <index-see> element and the <index-see-also> element.

The <index-see> element points to an index entry that should replace the current one.

<indexterm>Dokumentation
    <index-see>Technische Dokumentation</index-see>
</indexterm>

The <index-see-also> element points to an index entry that can be used alongside the current one.

<indexterm>Darwin Information Typing Architecture <index-see-also>DITA</index-see-also></indexterm>

DITA 1.1 also allows the sort order of an index entry to be specified. For example, an element name such as <topic> should be sorted among other element names under its initial letter rather than under the opening angle bracket (<). Use the <index-sort-as> element for this.

To sort the <topic> element under the keyword topic, use the following entry with the <index-sort-as> element:

<indexterm>&lt;topic&gt; <index-sort-as>topic</index-sort-as></indexterm>

  

 

 

 

back to top