An Oxygen Publishing Template package for WebHelp output must contain a template descriptor file and at least one CSS file, and may contain other resources (such as graphics, XHTML files, XSLT files, etc.). All the template resources can be stored in either a ZIP archive or in a folder. It is recommended to use a ZIP archive because it is easier to share with others.
Each publishing template includes a descriptor file that defines the meta-data associated with the template. It is an XML file that defines all the resources included in a template (such as CSS files, images, JS files, and transformation parameters).
The template descriptor file must have the .opt file extension and must be located in the template's root folder.
A template descriptor might look like this:
<publishing-template>
<name>Flowers</name>
<webhelp>
<tags>
<tag>tree</tag>
<tag>light</tag>
</tags>
<preview-image file="flowers-tree.png"/>
<!-- Resources (CSS, favicon, logo and others) -->
<resources>
<!-- Main CSS file -->
<css file="flowers.css"/>
<!-- Resources to copy to the output folder -->
<fileset>
<include name="resources/**/*"/>
<exclude name="resources/**/.svn"/>
<exclude name="resources/**/.git"/>
</fileset>
</resources>
<parameters>
<parameter name="webhelp.show.main.page.tiles" value="no"/>
<parameter name="webhelp.show.main.page.toc" value="yes"/>
<parameter name="webhelp.top.menu.depth" value="3"/>
</parameters>
</webhelp>
</publishing-template>
Each template descriptor file requires a <name> element. This
information is displayed as the name of the template in the transformation scenario dialog
box.
Optionally, you can include a <description> and it displayed when
the user hovers over the template in the transformation scenario dialog box.
<publishing-template>
<name>Lorem Ipsum</name>
<description>Lorem ipsum dolor sit amet, consectetur adipiscing elit</description>
...
Optionally, you can include author information in the descriptor file and it displayed when the user hovers over the template in the transformation scenario dialog box. This information might be useful if users run into an issue or have questions about a certain template.
If you include the <author> element, a
<name> is required and optionally you can include
<email>, <organization>, and
<organizationUrl> information.
<publishing-template>
...
<author>
<name>John Doe</name>
<email>jdoe@example.com</email>
<organization>ACME</organization>
<organizationUrl>http://www.example.com/jdoe</organizationUrl>
</author>
...
The <webhelp> element contains various details
that define the WebHelp Responsive output. It is a required element if you intend on using
a WebHelp Responsive transformation scenario. The elements that are allowed in this
<webhelp> section specify the template tags, template preview
image, resources (such as
CSS, JS, fonts, logos), transformation parameters, HTML fragment extensions (used to add fragments to placeholders),
XSLT extensions, or HTML page layout files.
<webhelp>
<tags>
...
</tags>
<preview-image file="MyPreview.png"/>
<resources>
...
</resources>
<html-page-layouts>
...
</html-page-layouts>
<parameters>
...
</parameters>
</webhelp>
The <tags> section provides meta information about the template
(such as layout type or color theme). Each tag is displayed at the top of the
Templates tab window in the transformation scenario dialog box
and they help the user filter and find particular templates.
<publishing-template>
...
<webhelp>
<tags>
<tag>tree</tag>
<tag>dark</tag>
</tags>
The <preview-image> element is used to specify an image that will
be displayed in the transformation scenario dialog box. It provides a visual
representation of the template to help the user select the right template. The image
dimensions should be 200 x 115 pixels and the supported image formats
are: JPEG, PNG, or GIF.
<online-preview-url> element to specify
the URL of a published sample of your template. This will display an
Online preview icon in the bottom-right
corner the image in the transformation scenario dialog box and if the user clicks that
icon, it will open the specified URL in their default
browser.<publishing-template>
...
<webhelp>
...
<preview-image file="ashes/ashes-tree.png"/>
<online-preview-url>https://www.example.com/samples/tiles/ashes</online-preview-url>The <resources> section of the descriptor file specifies a set of
resources (CSS, JS, fonts, logos, graphics, etc.) that are used to customize various
components in the generated output. These resources will be copied to the output folder
during the transformation process. At least one CSS file must be included, while the other
types of resources are optional.
@file
attribute must be relative.<resources>
element and the types of resources that can be specified include:<css> element.<favicon> element.<logo> element. Optionally, you can also specify:@target-url - Redirects the user to the
specified URL if they click the logo in the output.@new-tab - Opens the target URL in a new browser tab.@alt - Provides an alternate text for the logo
image. <fileset> element and you can use one or more
<include> and <exclude> elements. This
semantic is similar to the ANT FileSet.<publishing-template>
...
<webhelp>
...
<resources>
<css file="css/custom_styles.css"/>
<css file="css/custom_fonts.css"/>
<favicon file="images/favicon.png"/>
<logo
file="images/logo.png"
target-url="http://www.example.com"
alt="Alternate text for the logo image"
new-tab="true"/>
<js-amd-module file="js/template-main.js"/>
<fileset>
<include name="common/**/*"/>
<include name="JS/**/*"/>
<exclude name="**/*.svn"/>
<exclude name="**/*.git"/>
</fileset>
</resources>The resources specified in the template descriptor are copied to the following output folder: [WebHelp_OUTPUT_DIR]/oxygen-webhelp/template. The following graphic illustrates the mapping between the template resources and the location where they will be copied to the output folder:
<publishing-template>
...
<webhelp>
...
<parameters>
<parameter
name="webhelp.show.main.page.toc"
value="yes"/>
<parameter
name="webhelp.top.menu.depth"
value="3"/>
<parameter
name="webhelp.fragment.welcome"
value="html-fragment/webhelp.fragment.welcome.html"
type="filePath"/>
</parameters>
</webhelp>The following information can be specified in the <parameter>
element:
string or filepath. The
string value is default.After creating a publishing template and adding it to the templates gallery, when you select the template in the transformation scenario dialog box, the Parameters tab will automatically be updated to include the parameters defined in the descriptor file. These parameters are displayed in italics.
<xslt> element in the descriptor file using the following
structure:<publishing-template>
...
<webhelp>
...
<xslt>
<extension
id="com.oxygenxml.webhelp.xsl.dita2webhelp"
file="xsl/customDita2webhelp.xsl"/>
<extension
id="com.oxygenxml.webhelp.xsl.createMainPage"
file="xsl/customMainPage.xsl"/>
</xslt>getParameter(param.name) function
from the http://www.oxygenxml.com/functions namespace.The HTML pages contain component placeholders that can be used to insert custom HTML fragments either by specifying a well-formed XHTML fragment or referencing a path to a file that contains a well-formed XHTML fragment (for details on how the file or fragment needs to be constructed, see How to Insert Custom HTML Content).
<fragment> element inside the
<html-fragments> section. You can specify one or more HTML fragment
extension points in the descriptor file using the following
structure:<publishing-template>
...
<webhelp>
...
<html-fragments>
<fragment
file="html-fragments/webhelp_fragment_welcome.html"
placeholder="webhelp.fragment.welcome"/>
<fragment
file="html-fragments/webhelp_fragment_footer.html"
placeholder="webhelp.fragment.footer"/>
</html-fragments>Some of these placeholders are left empty in the default output configurations, but you can use them to insert custom content.
Each placeholder has an associated parameter value in the transformation. Some of the placeholder parameters are global and can be used in all type of pages (main page, topic page, search results page, index terms page), while others are applicable for certain type of pages. The following diagram illustrates the predefined placeholders that are global (can be used in any of the types of pages.
If you use strings for values of HTML fragment placeholder parameter values, the string values are written to files in the transformation's temporary directory. The values of the associated parameters reference the paths of the temporary files. This means that the HTML fragments will have a uniform processing in the WebHelp's XSLT Module.
Example:
# String value
webhelp.fragment.welcome = <p>This is an HTML paragraph.</p>A new file that contains the parameter's value is created:
<p>This is an HTML paragraph.</p># Absolute file path as value
webhelp.fragment.welcome= [temp-dir]/whr-html-fragments/webhelp_fragment_welcome.xmlYou can use the whc:macro layout component to specify a macro value (a
variable that will be expanded when the output files are generated).
${macro-name}or${macro-name(macro-parameter)}A macro name can accept any alphanumeric characters, as well as the following characters:
- (minus), _ (underscore), . (dot),
: (colon). The value of a parameter may contain any character except the
} (close curly bracket) character.
${i18n(string.id)}${param(webhelp.show.main.page.tiles)}${env(JAVA_HOME)}${system-property(os.name)}format-dateTime function
specification.${timestamp([h1]:[m01] [P] [M01]/[D01]/[Y0001])}${path(oxygen-webhelp-template-dir)} wh-macro-custom-path template from
com.oxygenxml.webhelp.responsive\xsl\template\macroExpander.xsl:
<!-- Extension template for expanding a custom path macro. -->
<xsl:template name="wh-macro-custom-path">
<xsl:param name="pathId"/>
<xsl:value-of select="$pathId"/>
</xsl:template> ${map-xpath(/map/title)}${topic-xpath(string-join(//shortdesc//text(), ' '))}${oxygen-webhelp-build-number} wh-macro-extension template from the
com.oxygenxml.webhelp.responsive\xsl\template\macroExpander.xsl
file.<!-- Extension template for expanding custom macro constructs -->
<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="$contextNode instance of attribute()">
<xsl:value-of select="$matchedString"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>Cannot expand macro:
[<xsl:value-of select="$matchedString"/>]</xsl:message>
<xsl:copy-of select="$contextNode"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>wh-macro-extension template has the following parameters:string sequence. The current macros parsing mechanism
only allows macros with a maximum of one parameter. Consequently, this list
will contain at most one element.<webhelp> and
<pdf> element and some of the resources can be reused. Resources
referenced in elements in the <webhelp> element will only be used for
WebHelp transformations, and resources referenced in the elements in the
<pdf> element will only be used in PDF
transformations.<publishing-template>
<name>Flowers</name>
<description>Flowers themed light-colored template</description>
<webhelp>
<tags>
<tag>purple</tag>
<tag>light</tag>
</tags>
<preview-image file="flowers-preview.png"/>
<resources>
<css file="flowers-wh.css"/>
<css file="flowers-page-styling.css"/>
</resources>
<parameters>
<parameter name="webhelp.show.main.page.tiles" value="no"/>
<parameter name="webhelp.show.main.page.toc" value="yes"/>
</parameters>
</webhelp>
<pdf>
<tags>
<tag>purple</tag>
<tag>light</tag>
</tags>
<preview-image file="flowers-preview.png"/>
<resources>
<css file="flowers-pdf.css"/>
<css file="flowers-page-styling.css"/>
</resources>
<parameters>
<parameter name="show.changes.and.comments" value="yes"/>"/>
</parameters>
<pdf>
</publishing-template>