How to Use XSLT Extension Points from a Publishing TemplateEdit online
This example demonstrates how to use WebHelp XSLT-import Extension Points from an Oxygen Publishing Template.
Use Case 1: Add Copyright Information Extracted from a DITA BookmapEdit online
Suppose you want to customize the WebHelp Responsive main page by adding information about the legal rights associated with the book in the footer (for example, copyright dates and owner). This information is specified in the bookmap:
<bookrights>
<copyrfirst>
<year>2002</year>
</copyrfirst>
<copyrlast>
<year>2017</year>
</copyrlast>
<bookowner>
<organization>SyncRO Soft SRL</organization>
</bookowner>
</bookrights>
The XSLT stylesheet that generates the main page 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>
In the following example, 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"> ©<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"> ©<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>
To add this functionality using a Oxygen Publishing Template , follow these steps:
<publishing-template>
...
<webhelp>
...
<xslt>
<extension
file="xslt/customMainPage.xsl"
id="com.oxygenxml.webhelp.xsl.createMainPage"/>
Use Case 2: Add generation time in the output footerEdit online
Another possible customization for the main page is to add the generation time in its footer. A transformation parameter is used to control whether or not this customization is active.
To add this functionality, follow these steps: