Pages: 1
Print
Author Topic: Format <codeph> element in TOC (PDF)  (Read 2002 times)
txvia
Member

Posts: 44


« on: January 12, 2012, 04:38:39 PM »

Hi all, I have to output an API user's guide in which some of the topic titles are actual API names and are formatted as <codeph> (i.e. these API names are in the <codeph> tag) in DITA source files, what I want to do is to have these API names formatted as <codeph> in TOC, but my problem is, I could not tell the PDF transform to just format the API names in <codeph> and leave the rest alone, instead, I could only get around to have the entire TOC titles that contain API names formatted as <codeph>, what I really want is just the ones wrapped in <codeph> to be output as <codeph>.

Here is an example:
My ditamap:

Table of Contents
Chapter 1......
 Introduction to <codeph>API calls</codeph>
Chapter 2...
........

In the example above, I only want "API calls" to be output as <codeph>, meaning output in monospaced font, and not the entire sentence; texts other than the ones wrapped in <codeph> should be output in the default font defined in the stylesheet. But I could only get around to have the entire topic title output in monospaced font. I scratched my head and couldn't figure out what went wrong.

What I've done so far is this:

In %appdata%/SoftQuad/XMetaL Shared/DITA_OT/demo/xmfo/Customization/fo/attrs/xm-cfg/toc-attr.xsl , I modified the font family attribute under  <xsl:attribute-set name="__toc__topic__content">:

.....
      <xsl:attribute name="font-family">
         <xsl:variable name="codeph" select="*[contains(@class, ' topic/title ')]/*[contains(@class, ' pr-d/codeph ')]"/>
            <xsl:choose>
               <xsl:when test="$codeph">Monospaced</xsl:when>
               <xsl:otherwise>HelveticaNeueLTStd</xsl:otherwise>
            </xsl:choose>
      </xsl:attribute>
.....

Result:

Chapter 1......
 Introduction to API calls
Chapter 2...

What I really want is:

Chapter 1......
 Introduction to API calls
Chapter 2...

Any help I can get is greatly appreciated.

Logged
Pages: 1
Print
Jump to: