Skip to content

Bookmap Copyright Info

Alin Balasa edited this page Apr 17, 2018 · 9 revisions

Template containing XSLT extensions that can transfer meta information specified in the DITA map to the WebHelp Responsive footer.

Use case

Suppose you want to customize the WebHelp Responsive pages by adding information about the legal rights associated with the book in the footer (for example, copyright dates and owner). images/bookmap-copyright-info.png

For this template to achieve its purpose, the following information needs to be specified in the bookmap:

<bookrights>            
  <copyrfirst>
    <year>2002</year>
  </copyrfirst>
  <copyrlast>
    <year>2017</year>
  </copyrlast>
  <bookowner>
    <organization>SyncRO Soft SRL</organization>                
  </bookowner>
</bookrights>

In order to modify the content of the footer section, first we need to identify the XSLT template that generates this compoent. We will use the XSLT stylesheet that generates the main page as a starting point. It is located in: DITA-OT-DIR\plugins\com.oxygenxml.webhelp.responsive\xsl\mainFiles\createMainPage.xsl. This XSLT stylesheet declares the copy_template mode that processes the main page template to expand its components.

The main page template declares a component for the footer section that looks like this:

<div class=" footer-container text-center ">
  <whc:include_html href="${webhelp.fragment.footer}"/>
</div>

The extension stylesheet will add a template that matches this component. It applies the default processing and adds the copyright information at the end.

<xsl:template match="*:div[contains(@class, 'footer-container')]" mode="copy_template">
  <!-- Apply the default processing -->
  <xsl:next-match/>

  <!-- Add a div containing the copyright information -->
  <div class="copyright_info">
    <xsl:choose>
      <!-- Adds the start-end years if they are defined -->
      <xsl:when
        test="
          exists($toc/*:topicmeta/*:bookrights/*:copyrfirst) and
          exists($toc/*:topicmeta/*:bookrights/*:copyrlast)">
        <span class="copyright_years"> &#xa9;<xsl:value-of
            select="$toc/*:topicmeta/*:bookrights/*:copyrfirst"/> -<xsl:value-of
            select="$toc/*:topicmeta/*:bookrights/*:copyrlast"/>
        </span>
      </xsl:when>

      <!-- Adds only the first year if last is not defined. -->
      <xsl:when test="exists($toc/*:topicmeta/*:bookrights/*:copyrfirst)">
        <span class="copyright_years"> &#xa9;<xsl:value-of
            select="$toc/*:topicmeta/*:bookrights/*:copyrfirst"/>
        </span>
      </xsl:when>
    </xsl:choose>


    <xsl:if test="exists($toc/*:topicmeta/*:bookrights/*:bookowner/*:organization)">
      <span class="organization">
        <xsl:text> </xsl:text>
        <xsl:value-of select="$toc/*:topicmeta/*:bookrights/*:bookowner/*:organization"/>
        <xsl:text>. All rights reserved.</xsl:text>
      </span>
    </xsl:if>
  </div>
</xsl:template>

The Publishing Template descriptor file contributes the extension stylesheet on the available XSLT extension points.

<publishing-template>
    <name>Bookmap Copyright Info</name>
    <!-- .... -->
    <webhelp>
        <!-- .... -->
        <xslt>
            <extension file="xslt/copyright-info.xsl" id="com.oxygenxml.webhelp.xsl.createMainPage"/>
            <extension file="xslt/copyright-info.xsl" id="com.oxygenxml.webhelp.xsl.dita2webhelp"/>
            <extension file="xslt/copyright-info.xsl" id="com.oxygenxml.webhelp.xsl.createSearchPage"/>
            <extension file="xslt/copyright-info.xsl" id="com.oxygenxml.webhelp.xsl.createIndexTermsPage"/>
        </xslt>
        <!-- .... -->
    </webhelp>
</publishing-template>

Template Resources

  • dita/it-book/ - Contains the DITA map sample that can be published using this template
  • templates/bookmap-copyright-info/ - The Bookmap Copyright Info Publishing Template package (read more about the package contents)
    • resources/images - Contains the background images used in this template.
    • resources/xslt - Contains the XSLT extension files.
    • oxygen.css - The base CSS that defines the styles of the WebHelp output
    • oxygen-tiles.png - Preview image.
    • bookmap-copyright.opt - The Publishing Template descriptor file

How to use this template

  1. Open the dita/it-book/taskbook.ditamap DITA map in the DITA Maps Manager view
  2. Open the Configure Transformation Scenario(s) dialog
  3. Duplicate the DITA Map WebHelp Responsive built-in transformation scenario
  4. Select the Bookmap Copyright Info template
  5. Click OK to save the scenario
  6. Apply the transformation scenario to publish the DITA map to WebHelp Responsive format.

Publishing Templates:

Clone this wiki locally