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.
Specific information regarding the modification of the DTD and XSL files are provided below.
The fmxbook.dtd file is found in the Book application’s dtd folder.
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 >
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 >
Save and close the DTD 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.
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>
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>
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>
Save and close the XSL file.