Hello,
The above statement refers to the fact that you have the possibility to add (implement) a custom named macro besides the ones already available (listed here:
https://www.oxygenxml.com/doc/versions/ ... 2b__d75e47).
For example, the implementation for a macro named
my-macro can look as follows (note that this is a dummy implementation for demo purposes):
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template name="wh-macro-extension">
<xsl:param name="name"/>
<xsl:param name="params"/>
<xsl:param name="contextNode"/>
<xsl:param name="matchedString"/>
<xsl:choose>
<xsl:when test="$name eq 'my-macro'">
<p>This is an implementation for the <pre><xsl:value-of select="$name"/></pre> macro called with
<xsl:choose>
<!-- As the docs say, the $params sequence can contain maximum one parameter -->
<xsl:when test="count($params) > 0"> the following parameters: <pre><xsl:value-of select="string-join($params, ',')"/></pre></xsl:when>
<xsl:otherwise> no parameters.</xsl:otherwise>
</xsl:choose>
</p>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
No, you do not have to create a new plugin. You can use the XSLT Extension support from the Publishing Template (
https://www.oxygenxml.com/doc/versions/ ... ing_templa).
Depending on which page you want your macro implementation to be available in, you have to use the following extension points:
- com.oxygenxml.webhelp.xsl.createMainPage - for the Main page (index.html)
- com.oxygenxml.webhelp.xsl.dita2webhelp - for the pages generated from the DITA topics
- com.oxygenxml.webhelp.xsl.createSearchPage - for the Search Results page
- com.oxygenxml.webhelp.xsl.createIndexTermsPage - for the Index Terms page
Assuming that you want your macro to be available in all pages and you have saved the above XSLT content in a file named
macro-implemetation.xsl located in the root directory of your Publishing Template (next to your template descriptor (OPT) file), you should add the following lines in your template descriptor:
Code: Select all
<xslt>
<extension file="macro-implemetation.xsl" id="com.oxygenxml.webhelp.xsl.createMainPage"/>
<extension file="macro-implemetation.xsl" id="com.oxygenxml.webhelp.xsl.dita2webhelp"/>
<extension file="macro-implemetation.xsl" id="com.oxygenxml.webhelp.xsl.createSearchPage"/>
<extension file="macro-implemetation.xsl" id="com.oxygenxml.webhelp.xsl.createIndexTermsPage"/>
</xslt>
As you can see I have linked my XSLT extension file to the XSLT extension points associated with each page type.
Next, you can use your custom
my-macro macro in an HTML Fragment file as follows
(
https://www.oxygenxml.com/doc/versions/ ... aid-title6):
Code: Select all
<div class="footer" xmlns:whc="http://www.oxygenxml.com/webhelp/components">
<whc:macro value="${my-macro(my-macro-param)}"/>
</div>
In order to include the above content in the footer section of each page you can add the following lines in your Publishing Template descriptor file:
Code: Select all
<html-fragments>
<fragment file="footer-fragment.xml" placeholder="webhelp.fragment.footer"/>
</html-fragments>
Again, I assumed that the HTML Fragment file is named
footer-fragment.xml and it is located in your template's root directory.
The footer section will look as follows:
The Publishing Template containing the above resources can be found here:
http://www.oxygenxml.com/forum/files/custom-macro.zip
Regards,
Alin