Using localized variables in webhelp HTML fragments

Post here questions and problems related to editing and publishing DITA content.
eccc
Posts: 16
Joined: Mon Apr 23, 2018 8:38 am

Using localized variables in webhelp HTML fragments

Post by eccc »

Hi,

We're created a customization of the responsive webhelp plugin where we run custom XSLT tasks for generating HTML fragments with localized texts (such as "Last updated" in the footer) from the webhelp localization framework. Is there any easier way to do this, especially with the new publishing templates, so that I wouldn't need to use XSLT tasks to generate the fragments?

Additionally, what kind of variables can I use in a publishing template? For example, I'd like to refer to the output folder (which can of course change depending on the environment) in the publishing template by using a variable that stores the location of the output folder during build time. Is that possible?

Best regards,
Antti
alin
Site Admin
Posts: 268
Joined: Thu Dec 24, 2009 11:21 am

Re: Using localized variables in webhelp HTML fragments

Post by alin »

Hello,
eccc wrote:We're created a customization of the responsive webhelp plugin where we run custom XSLT tasks for generating HTML fragments with localized texts (such as "Last updated" in the footer) from the webhelp localization framework. Is there any easier way to do this, especially with the new publishing templates, so that I wouldn't need to use XSLT tasks to generate the fragments?
Unfortunatelly, you cannot contribute custom localized strings using the Publishing Template. However, you can use the Publishing Template to contribute your customization stylesheets. Here is an example in our User Manual: https://www.oxygenxml.com/doc/versions/ ... mport.html
You can find the Publishing Templates derived from the above example in the following GitHub project: https://github.com/oxygenxml/oxygen-pub ... omizations
eccc wrote:Additionally, what kind of variables can I use in a publishing template? For example, I'd like to refer to the output folder (which can of course change depending on the environment) in the publishing template by using a variable that stores the location of the output folder during build time. Is that possible?
Can you please give us more details about your use case? More specific, where do you want to use such a variable for the output directory: in the Publishing Template descriptor file (opt) or in an HTML fragment file? For the HTML fragment file you can refer to the following topic in our User Guide: https://www.oxygenxml.com/doc/versions/ ... -html.html

Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
eccc
Posts: 16
Joined: Mon Apr 23, 2018 8:38 am

Re: Using localized variables in webhelp HTML fragments

Post by eccc »

alin wrote: Unfortunatelly, you cannot contribute custom localized strings using the Publishing Template. However, you can use the Publishing Template to contribute your customization stylesheets. Here is an example in our User Manual: https://www.oxygenxml.com/doc/versions/ ... mport.html
You can find the Publishing Templates derived from the above example in the following GitHub project: https://github.com/oxygenxml/oxygen-pub ... omizations
We use a custom XSL template to generate, for example, the webhelp.fragment.footer fragment out of an XML file. How would I be able to execute the custom XSLT transformation via the publishing template? I don't see a suitable extension point for it.
alin wrote: Can you please give us more details about your use case? More specific, where do you want to use such a variable for the output directory: in the Publishing Template descriptor file (opt) or in an HTML fragment file? For the HTML fragment file you can refer to the following topic in our User Guide: https://www.oxygenxml.com/doc/versions/ ... -html.html
I'd like to be able to refer to the output folder using a variable in the OPT file. The HTML fragments are regenerated by XSLT transformations whenever the webhelp output is built and I'd like to be able to store the generated HTML fragments in the output folder instead of the DITA-OT folder so that the DITA-OT folder remains "clean".
alin
Site Admin
Posts: 268
Joined: Thu Dec 24, 2009 11:21 am

Re: Using localized variables in webhelp HTML fragments

Post by alin »

Hello,

I hope I have correctly understood your use case. Please correct me if I am wrong.
So, you are trying to customize the content of the footer sections in the WebHelp Responsive output HTML pages.
I understand that your custom content is not static and you need to regenerate it at each transformation.
Thus generating an intermediate HTML fragment file is not the best approach in this case.

You should register an XSLT extension file which overrides the template that outputs the default footer content. Use this template to directly generate your custom footer content in each HTML page. This way you will not have to generate an additional HTML fragment file and then reference that file using the "webhelp.fragment.footer" parameter.
For this you will have to register your XSLT file on the following XSLT extension points:
  • com.oxygenxml.webhelp.xsl.dita2webhelp
  • com.oxygenxml.webhelp.xsl.createMainPage
  • com.oxygenxml.webhelp.xsl.createSearchPage
  • com.oxygenxml.webhelp.xsl.createIndexTermsPage

A stub for the template that will generate your custom content may look like this:

Code: Select all


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

<!-- Add a div containing your custom footer content -->
<div class="custom-footer">
<!-- Generate your content here -->
</div>
</xsl:template>
We have a similar example in our User Manual: https://www.oxygenxml.com/doc/versions/ ... mport.html

Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply