Use Case 2: WebHelp XSLT-parameter extension point to control if generation time is displayed in the output
Another possible customization for the main page is to add the generation time in its footer. You can use an XSLT-Parameter extension point to control if this customization is active or not. In this case, you can use the com.oxygenxml.webhelp.xsl.createMainPage.param extension point.
To add this functionality, follow these steps:
- In the [DITA-OT DIR]\plugins\ folder, create a folder for this plugin (for example, com.oxygenxml.webhelp.responsive.custom.footer).
-
Create a plugin.xml file (in the folder you created in step 1) that
specifies the extension point and your customization stylesheet. For
example:
<plugin id="com.oxygenxml.webhelp.responsive.custom.footer"> <feature extension="com.oxygenxml.webhelp.xsl.createMainPage" file="custom_mainpage.xsl"/> </plugin>
-
Create your customization stylesheet (for example, custom_mainpage.xsl),
and edit it to override the template that produces the footer section:
<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>
-
In the customization stylesheet that you just created (for example,
custom_mainpage.xsl), declare
webhelp.footer.add.generation.time
as a global parameter and modify the template by adding the following XSLT code at the end.<xsl:if test="$webhelp.footer.add.generation.time = 'yes'"> <div class="generation_time"> Generation date: <xsl:value-of select="format-dateTime( current-dateTime(), '[h1]:[m01] [P] on [M01]/[D01]/[Y0001].')"/> </div> </xsl:if>
-
Edit the plugin.xml file to specify the
com.oxygenxml.webhelp.xsl.createMainPage.param extension point and a
custom parameter file by adding the following line:
<feature extension="com.oxygenxml.webhelp.xsl.createMainPage.param" file="params.xml"/>
-
Create a custom parameter file (for example, params.xml). It should look
like this:
<dummy> <param name="webhelp.footer.add.generation.time" expression="${webhelp.footer.add.generation.time}" if="webhelp.footer.add.generation.time"/> </dummy>
- Use the Run DITA-OT Integrator transformation scenario found in the DITA Map section in the Configure Transformation Scenario(s) dialog box.
-
In the [DITA-OT DIR]/bin directory of the DITA-OT, run one
of the following scripts, depending on your operating system:
- Windows:
[DITA-OT DIR]/bin/dita.bat --install
- Linux:
[DITA-OT DIR]/bin/dita.sh --install
- Windows: