Can I include specific HTML fragment files in XSLT templates?
Posted: Mon Jul 18, 2022 11:32 pm
WebHelp topic pages have a "right tools" group that contains various topic-related tools (collapse, previous/next topic, print, etc.):
I would like to add my own tool to this group in a WebHelp publishing template, and I would like to use an HTML fragment so I can use macro evaluation. So, I created an XSLT file that calls <whc:include_html> with a specific @href path:
but the @href path is interpreted as HTML content to insert directly:
But if I define and use my own (nonstandard) fragment parameter:
then it works as desired.
Is there a trick to directly specifying a fragment filename with the @href attribute of a <whc:include> element? Or is this unsupported and fragments must be specified through the fragment parameter framework? I can use the nonstandard parameter approach, but if a simpler solution exists, I should use it.
A testcase is included:
To run,
1. Publish all deliverables in "project.xml".
2. Explore the WebHelp results in out/good/ (which uses a parameter) and out/bad/ (which uses a specified file path).
I would like to add my own tool to this group in a WebHelp publishing template, and I would like to use an HTML fragment so I can use macro evaluation. So, I created an XSLT file that calls <whc:include_html> with a specific @href path:
Code: Select all
<!-- evaluate our own fragment placeholder at the end -->
<xsl:variable name="my-tool-placeholder">
<whc:include_html href="../html-fragments/my-tool.xhtml"/>
</xsl:variable>
<xsl:apply-templates select="$my-tool-placeholder" mode="copy_template"/>
But if I define and use my own (nonstandard) fragment parameter:
Code: Select all
<!-- evaluate our own fragment placeholder at the end -->
<xsl:variable name="my-tool-placeholder">
<whc:include_html href="{'${webhelp.fragment.my.tool}'}"/>
</xsl:variable>
<xsl:apply-templates select="$my-tool-placeholder" mode="copy_template"/>
Is there a trick to directly specifying a fragment filename with the @href attribute of a <whc:include> element? Or is this unsupported and fragments must be specified through the fragment parameter framework? I can use the nonstandard parameter approach, but if a simpler solution exists, I should use it.
A testcase is included:
To run,
1. Publish all deliverables in "project.xml".
2. Explore the WebHelp results in out/good/ (which uses a parameter) and out/bad/ (which uses a specified file path).