Topic Specialization Step 4-3: Copy Template Contents from Base XSLTs

In the Open Toolkit distribution, find the file dita2htmlImpl.xsl. It should be in the xsl/xslhtml directory.

Within this file, find the template that matches on " topic/title " within " topic/topic " (again, the spaces at the beginning and end are significant). This can sometimes be a challenge because the indirect nature of the matches can make it hard to find the specific template you need. One technique is to search on " topic/title " and keep repeating the search until you find the template you're looking for. In this case, you should find this template:
<!-- NESTED TOPIC TITLES (sensitive to nesting depth, but are still processed for contained markup) -->
<!-- 1st level - topic/title -->
<!-- Condensed topic title into single template without priorities; use $headinglevel to set heading.
     If desired, somebody could pass in the value to manually set the heading level -->
<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
  <xsl:param name="headinglevel">
      <xsl:choose>
          <xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')]) > 6">6</xsl:when>
          <xsl:otherwise><xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ')])"/></xsl:otherwise>
      </xsl:choose>
  </xsl:param>
  <xsl:element name="h{$headinglevel}">
      <xsl:attribute name="class">topictitle<xsl:value-of select="$headinglevel"/></xsl:attribute>
      <xsl:call-template name="commonattributes"/>
      <xsl:apply-templates/>
  </xsl:element>
  <xsl:value-of select="$newline"/>
</xsl:template>      
Copy everything inside the <xsl:template> element and paste it into the template for <faq-question-statement> in faq-question2html.xsl, which should now look like this:
<xsl:template match="*[contains(@class, ' faq-question/faq-question-statement ')]">
  <xsl:param name="headinglevel">
      <xsl:choose>
          <xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')]) > 6">6</xsl:when>
          <xsl:otherwise><xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ')])"/></xsl:otherwise>
      </xsl:choose>
  </xsl:param>
  <xsl:element name="h{$headinglevel}">
      <xsl:attribute name="class">topictitle<xsl:value-of select="$headinglevel"/></xsl:attribute>
      <xsl:call-template name="commonattributes"/>
      <xsl:apply-templates/>
  </xsl:element>
  <xsl:value-of select="$newline"/>
</xsl:template>  
 
For <faq-answer>, we want the processing applied to concept/conbody. However, if you search for " concept/conbody " you won't find anything, which means that there is no special processing for <conbody>. That means you must search for the next level up the specialization hierarchy (" topic/body "). Copy the contents of that template into the template for <faq-answer>:
<xsl:template match="*[contains(@class, ' faq-question/faq-answer ')]">
  <xsl:variable name="flagrules">
    <xsl:call-template name="getrules"/>
  </xsl:variable>
<div>
  <xsl:call-template name="commonattributes"/>
  <xsl:call-template name="gen-style">
    <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="setidaname"/>
  <xsl:call-template name="start-flagit">
    <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>     
  </xsl:call-template>
  <xsl:call-template name="start-revflag">
    <xsl:with-param name="flagrules" select="$flagrules"/>  
  </xsl:call-template>
  <!-- here, you can generate a toc based on what's a child of body -->
  <!--xsl:call-template name="gen-sect-ptoc"/--><!-- Works; not always wanted, though; could add a param to enable it.-->

  <!-- Insert prev/next links. since they need to be scoped by who they're 'pooled' with, apply-templates in 'hierarchylink' mode to linkpools (or related-links itself) when they have children that have any of the following characteristics:
       - role=ancestor (used for breadcrumb)
       - role=next or role=previous (used for left-arrow and right-arrow before the breadcrumb)
       - importance=required AND no role, or role=sibling or role=friend or role=previous or role=cousin (to generate prerequisite links)
       - we can't just assume that links with importance=required are prerequisites, since a topic with eg role='next' might be required, while at the same time by definition not a prerequisite -->

  <!-- Added for DITA 1.1 "Shortdesc proposal" -->
  <!-- get the abstract para -->
  <xsl:apply-templates select="preceding-sibling::*[contains(@class,' topic/abstract ')]" mode="outofline"/>
  
  <!-- get the shortdesc para -->
  <xsl:apply-templates select="preceding-sibling::*[contains(@class,' topic/shortdesc ')]" mode="outofline"/>
  
  <!-- Insert pre-req links - after shortdesc - unless there is a prereq section about -->
  <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/related-links ')]" mode="prereqs"/>

  <xsl:apply-templates/>
  <xsl:call-template name="end-revflag">
    <xsl:with-param name="flagrules" select="$flagrules"/>  
  </xsl:call-template>
  <xsl:call-template name="end-flagit">
    <xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param> 
  </xsl:call-template>
</div><xsl:value-of select="$newline"/>

</xsl:template>
For <faq-question>, add a next-match statement to the template body:
<xsl:template match="*[contains(@class, ' faq-question/faq-question ')]">
  <xsl:next-match/>
</xsl:template>

The next-match simply says "take the context node (that is, the <faq-question> element) and apply whatever template would have matched if this template hadn't matched." This has the effect of just applying the default formatting for concept topics, but it also gives us a ready-made place to add new or different processing should we need it. It also demonstrates the use of next-match.

If you redeploy the plugin and apply the Toolkit to your FAQ topics, you should again get the normal output. You can verify that you are really using your stylesheet by either introducing a syntax error and verifying that the processing fails, or by adding something to a template that will have a visual effect in the output. You can also use <xsl:message> to emit messages in the Toolkit log.

Once you have verified that everything is working as expected, you are ready to start modifying the processing.