XML technologies / DITA / Reusing content with maps and conref / Maps

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

In DITA, maps are the information structure used to organize topics. Maps assemble topics by reference, specifying both order and hierarchy.

The following sections explain how to

Referencing topics in maps

A map organizes topics into a hierarchical structure by referencing them. A map is also the starting point for creating a table of contents or online help navigation.

The basic structure of a map is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map id="buch_map">
    <title>Map Dita Buch</title>
    <topicref/>
</map>

A map file is an XML file and therefore begins with XML and DOCTYPE declarations. The DOCTYPE declaration references the map.dtd file, which in turn refers to the map.mod file defining the map elements.

A map is identified by the root element <map>. To reference a map unambiguously, assign it an ID.

The <title> element assigns the map a title. Online help displays this title in the window title; PDF files display it on the cover.

A map file is identified by the extension .ditamap. Many DITA-aware XML editors add this extension automatically when a map is first saved.

Topics are referenced using the <topicref> element. The href attribute, familiar from HTML’s <a> element, points to a topic.

For example, to reference the file maps_erstellen.xml in the same directory as the map file, use the <topicref> element as follows:

 <topicref href="maps_erstellen.xml"/> 

That is, the map file looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
    <map title="Map Dita Buch" id="buch_map">
    <topicref href="maps_erstellen"/>
</map>

<topicref> elements can be nested to any depth: a <topicref> element can contain further <topicref> elements. This builds a hierarchy familiar from conventional tables of contents.

If a <topicref> element contains no nested <topicref> element, the abbreviated form

 <topicref href="maps_erstellen.xml"/> 

can be used instead of

 <topicref href="maps_erstellen.xml"></topicref> 

, as in the example above. The / (slash) before the closing angle bracket indicates an empty element.

Nesting <topicref> elements is illustrated using the topics making up “Maps”. The individual subsections are stored in separate DITA XML files, which may contain, for example, the concept topic type:

  • topics_in_maps_referenzieren.xml

  • meta-daten_fuer_maps.xml

  • map_attribute.xml

  • das_chunk_attribut.xml

These four files are below the file maps_erstellen.xml in the hierarchy. The map file therefore looks as follows:

<?xml version="1.0" encoding="UTF-82"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map title="Map Dita Buch" id="buch_map">
    <topicref href="maps_erstellen.xml">
        <topicref href="topics_in_maps_referenzieren.xml" />
        <topicref href="meta-daten_fuer_maps.xml" />
        <topicref href="map_attribute.xml" />
        <topicref href="das_chunk_attribut.xml" />
    </topicref>
</map>

The DITA Open Toolkit ensures, when generating the output medium, that the hierarchy appears in the table of contents or the navigation structure appropriate to that medium. Navigation titles use the contents of the <title> elements or the <navtitle> elements in the referenced topics.

Adding more <topicref> elements extends the hierarchy further:

<?xml version="1.0" encoding="UTF-82"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map title="Map Dita Buch" id="buch_map">
    <topicref href="maps_erstellen.xml">
        <topicref href="topics_in_maps_referenzieren.xml"/>
        <topicref href="meta-daten_fuer_maps.xml" />
        <topicref href="map_attribute.xml" />
        <topicref href="das_chunk_attribut.xml" />
    </topicref>
    <topicref href="die_bookmap.xml">
        <topicref href="meta-daten_bookmap.xml" />
    </topicref>
</map>

As this example shows, topics are easily reused in maps. Simply copy the <topicref> element referencing the topic to be reused to the desired place in the hierarchy.

Within a map, you can also group <topicref> elements using the <topicgroup> element. Grouping does not affect the map hierarchy. The attributes of the <topicgroup> element are inherited by the enclosed <topicref> elements.

<topicgroup audience="beginner">
    <topicref href="installation.xml"/>
    <topicref href="konfiguration.xml"/>
</topicgroup>

To include only a topic’s unlinked title in a map, use the <topichead> element. You can use the
<topichead> element, for example, to include an unlinked title in the navigation.

 

Relationship tables

DITA provides relationship tables to express relationships between topics. A relationship table is defined by the <reltable> element, placed inside the <map> element.

<map>
    <reltable>
        ...
    </reltable>
    ...
</map>

The <relheader> element defines a relationship table’s header. In the <realheader> element, the number of <relcolspec> elements determines the number of columns. The header has only one row. In the <relcolspec> element, the type attribute specifies which topic type is listed in the column. Values for the type attribute are concept, task, reference and topic.

The <relrow> element defines a relationship table row.

Each column is defined by the <relcell> element. A topic referenced in a cell through a <topicref> element is related to the other topics listed in the row.

A complete relationship table might have the following structure:

<reltable>
    <relheader>
        <relcolspec type="concept"/>
        <relcolspec type="task"/>
        <relcolspec type="reference"/>
    </relheader>
    <relrow>
        <relcell>
            <topicref href="installation.xml"/>
        </relcell>
        <relcell>
            <topicref href="installieren.xml"/>
            <topicref href="konfigurieren.xml"/>
        </relcell>
        <relcell>
            <topicref href="parameter.xml"/>
        </relcell>
    </relrow>
</reltable>

This relationship table is displayed as follows:

type=“concept“

type=“task“

type=“reference“

installation.xml

installieren.xml konfigurieren.xml

parameter.xml

If a relationship table has multiple rows, relationships are defined only within each row. Relationship tables cannot define relationships across rows.

As the example shows, a cell may contain multiple topics. By default, DITA assumes topics in the same cell are unrelated. If they are related, group the <topicref> elements using the <topicgroup> element. The collection-type attribute specifies the relationship between topics in the <topicgroup> element. If the topics are related, set the collection-type attribute to family.

<relcell>
    <topicgroup collection-type="family">
        <topicref href="installieren.xml"/>
        <topicref href="konfigurieren.xml"/>
    </topicgroup>
</relcell>

 

Metadata in maps

In a map, metadata can be added to <topicref> elements through the <topicmeta> element.

If metadata appears in both the topic and map, the DITA Open Toolkit overwrites the topic metadata with map metadata when processing the map. For example, if the concept topic type maps_erstellen.xml uses the <shortdesc> element and the map file’s <topicmeta> element also uses it for a <topicref> element, the <short-desc> element from the map is used when producing the output medium.

The <topicmeta> element can contain the following elements:

  • <author>: identifies who compiled the topic.

<topicmeta>
    <author>Johannes Hentrich</author>
</topicmeta>

  • <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.

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

  • <copyright>: copyright information is recorded in the <copyright> element. Within the <copright> element, the <copyrholder> element gives the copyright holder’s name, and the <copyryear> element uses the year attribute to specify the copyright year.

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

  • <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. The <revised> element records when the topic was last revised, using the modified attribute.

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

  • <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, as the following example shows:

<topicmeta>
    <keywords>
        <keyword>DITA</keyword>
        <keyword>Meta-Daten</keyword>
        <keyword>Verschlagwortung</keyword>
    </keywords>
</topicmeta>

  • <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.

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

  • <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.

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

Attributes in maps

Attributes add information to a map to control its processing by the DITA Open Toolkit.

Maps often represent a hierarchy in which higher-level topics have a parent/child relationship with lower-level topics. Attributes and their values are inherited from parent to child. A parent topic’s attribute value is overridden only when a different value is set in the child topic.

The following attributes can be used in a map and its elements:

  • collection-type: the collection-type attribute specifies the relationship between topics. The value unordered means their order is unimportant for understanding. The value sequence means the listed order is important for understanding. The value choice means one child topic should be selected. The value family means the topics are related both to the current topic and to each other.

<topicref href="installation.xml" collection-type="sequence">
    <topicref href="konfiguration.xml"/>
</topicref>

  • format: the format attribute in the <topicref> element specifies the file type of the referenced topic or other resource. Possible values for the format attribute are dita, html, pdf and ditamap.

<topicref href="http://www.xlcontent-verlag.de" format="html"/>

  • linking: the linking attribute controls topic link direction in maps. With the value targetonly, links may lead to a topic but none may lead from it to other topics. The reverse applies with the value sourceonly: no link can lead to the topic, but links may lead from it to other topics. No links are possible with the value none. The default behavior, allowing links both to and from a topic, is expressed by the value normal.

<topicref href="about_author.xml" linking="sourceonly"/>

  • locktitle: the locktitle attribute specifies that the content of the navtitle attribute on the <topicref> element in the map is to be used. Possible values for the locktitle attribute are yes and no.

<topicref href="how_to_use_help.xml" navtitle="Help" locktitle="yes"/>

  • print: the print attribute specifies whether a topic referenced in a <topicref> element should be included in a PDF file. Possible values for the print attribute are yes, no and printonly. The printonly attribute suppresses output of the parent <topicref> element for output media other than PDF.
    The value of the print attribute is inherited by child <topicref> elements, where a local value overrides the inherited one.

 <topicref href="how_to_use_help.xml" print="no"/> 
  • scope: the scope attribute indicates where topics in DITA XML files are located relative to the map. The value local indicates that the topics and map are in the same directory or its subdirectories. The value peer indicates that the referenced resource is not in the same directory. During output production, a resource marked peer is not copied into the output directory. Entirely external resources, such as a website, receive the value external.

 <topicref href="http://www.xlcontent-verlag.de" scope="external"/> 
  • search: the search attribute specifies whether a topic referenced in a
    <topicref> element should be searchable through a search engine. Possible values for the search attribute are yes and no. The value of the search attribute is inherited by child <topicref> elements, where a local value overrides the inherited one.

 <topicref href="index.xml" search="no"/> 
  • toc: the toc attribute specifies whether a topic referenced in a <topicref> element should appear in the table of contents. Possible values for the toc attribute are yes and no. The value of the toc attribute is inherited by child <topicref> elements, where a local value overrides the inherited one.

 <topicref href="copyright.xml" toc="no"/> 
  • type: the type attribute in the <topicref> element specifies which topic type or particular element is referenced. Possible values for the type attribute are topic, task, concept, reference and fn (footnote), table, fig (figure), li (list) and section.

 <topicref href="installation.xml" type="task"/> 

Another important map attribute is the chunk attribute, introduced in the next section.

 

The chunk attribute

DITA 1.1 introduced the chunk attribute, allowing individual topic files to be combined into one file or a file containing many topics to be split into individual topic files. Combining several topic files may be needed, for example, to put multiple topics on one web page.

The chunk attribute can take one or more of the following values:

  • by-topic: the topic referenced in the <topicref> element is output as a separate unit for the target topic if the chunk attribute is set to by-topic. This also applies to child <topicref> elements.

<map>
    <topicref href="intro.xml" chunk="by-topic">
        <topicref href="preface.xml"/>
    </topicref>
</map>

  • by-document: a separate unit is output for the referenced document if the chunk attribute is set to by-document.

For example, given the following file named eins.xml:

<dita>
    <topic id="A"/>
    <topic id="B">
        <topic id="B1">
            <topic id="B1a"/>
        </topic>
        <topic id="B2"/>
    </topic>
    <topic id="C">
        <topic id="C1"/>
    </topic>
</dita>

the following map

<map chunk="by-document">
    <topicref href="start.xml" chunk="to-content">
        <topicref href="eins.xml#B1" chunk="select-topic"/>
    </topicref>
</map>

produces a single document start.xml containing the topic B1 from the file eins.xml. The value to-content (see below) produces a new unit. The value select-topic (see below) selects exactly one topic.

  • select-topic: the value select-topic selects one referenced topic from a document without its child topics.

  • select-document: the referenced topic and all other topics in the document are selected with the value select-document.

Again, given an example file named eins.xml:

<dita>
    <topic id="A"/>
    <topic id="B">
        <topic id="B1">
            <topic id="B1a"/>
        </topic>
        <topic id="B2"/>
    </topic>
</dita>

the following map

<map chunk="by-topic">
    <topicref href="start.dita" chunk="to-content">
        <topicref href="eins.xml#B1" chunk="select-document"/>
    </topicref>
</map>

produces a single document containing all topics from the file eins.xml.

  • select-branch: the value select-branch selects one topic and its contained topics.

Given an example file eins.xml

<dita>
    <topic id="A"/>
    <topic id="B">
        <topic id="B1">
            <topic id="B1a"/>
        </topic>
        <topic id="B2"/>
    </topic>
    <topic id="C">
        <topic id="C1"/>
    </topic>
</dita>

, the following map

<map chunk="by-document">
    <topicref href="eins.xml" chunk="to-content">
        <topicref href="eins.dita#B" chunk="select-branch"/>
    </topicref>
</map>

produces a single document containing the topics B1, B1a and B2.

  • to-content: the value to-content produces a new content unit during processing.

  • to-navigation: the value to-navigation produces a new navigation unit during processing.

  

 

 

 

back to top