Adding New fm-ditabook Attributes

Passing data from a DITA map to the generated FM book file can be accomplished by creating new attributes on the fm-ditabook element.

Two DITA-FMx features read the attribute values that exist on the fm-ditabook element (the root of a generated book file). These attributes can define values that are passed to the book components as FrameMaker variables. These attributes can also be used to control the show/hide state of conditions in the generated book components. For information on enabling these features see, Book-Build INI file.

In order to add your own attributes to the fm-ditabook element, you need to modify a number of files in the Book structure application. The following is an overview of the steps required; details are provided below.

  1. Modify the EDD to add attributes to the fm-ditabook element definition.
  2. Import the updated EDD into the Book template.
  3. Modify the fmxbook.dtd file to add the new attribute definitions.
  4. Modify the bookmap2fmbook.xsl file to copy the selected data into the new fm-ditabook attributes.

Specific information regarding the modification of the DTD and XSL files are provided below.

Modifying the fmxbook.dtd file

The fmxbook.dtd file is found in the Book application’s dtd folder.

  1. Open the fmxbook.dtd file and locate the attribute definitions for the fm-ditabook element. The unaltered attribute definition should look like the following.

    <!ATTLIST fm-ditabook 
        href CDATA #IMPLIED 
        format CDATA #IMPLIED 
        title CDATA #IMPLIED 
    >
  2. Add the new attributes. The example below adds a new “version” attribute.

    <!ATTLIST fm-ditabook 
        href CDATA #IMPLIED 
        format CDATA #IMPLIED 
        title CDATA #IMPLIED 
        version CDATA #IMPLIED 
    >
  3. Save and close the DTD file.

Modifying the bookmap2fmbook.xsl file

The bookmap2fmbook.xsl file is used to aggregate the DITA topics into a book file and component FM files. It can be used to copy data from the DITA map into attributes of the fm-ditabook element. Most likely you would copy data from the bookmeta or topicmeta elements, but any accessible element or attribute data could be used.

  1. Open the bookmap2fmbook.xsl file and locate the map and/or bookmap templates. It will depend on the type of data you’re copying as to which template you will work on. The map and bookmap templates begin with the following lines.

    <xsl:template match="map"> 
    ... 
    </xsl:template> 
     
    <xsl:template match="bookmap"> 
    ... 
    </xsl:template>
  2. Within each block is code that creates the fm-ditabook element.

    <fm-ditabook xsl:exclude-result-prefixes="ditaarch"> 
      <xsl:attribute name="format"> 
        <xsl:value-of select="@format"/> 
      </xsl:attribute> 
      <xsl:attribute name="title"> 
        <xsl:value-of select="$title_text"/> 
      </xsl:attribute> 
      <xsl:apply-templates/> 
    </fm-ditabook>
  3. The xsl:attribute element is used to add attributes to the fm-ditabook element in the generated FM book. To add a version attribute, insert the following code before the xsl:apply-templates element.

       <xsl:attribute name="version"> 
         <xsl:value-of select="/bookmeta/prodinfo/vrmlist/vrm/@version"/> 
       </xsl:attribute>
  4. Save and close the XSL file.