Webhelp XSLT glossentry override

Here should go questions about transforming XML with XSLT and FOP.
urbanrobots
Posts: 86
Joined: Sun May 03, 2015 7:34 pm
Location: San Francisco

Webhelp XSLT glossentry override

Post by urbanrobots »

Hi,

Where do we configure the glossary output structure for glossary entries in the Webhelp XSL files?

For the PDF plugin, we use the following template and FO blocks. We'd like to do something similar in the Webhelp plugin.

Code: Select all


   <xsl:template match="*[contains(@class,' glossentry/glossentry')]">

<xsl:variable name="glossSynonym" select="*[contains(@class, ' glossentry/glossBody ')]/*[contains(@class, ' glossentry/glossAlt ')]/*[contains(@class, ' glossentry/glossSynonym ')]/node()"/>
<xsl:variable name="glossAcronym" select="*[contains(@class, ' glossentry/glossBody ')]/*[contains(@class, ' glossentry/glossAlt ')]/*[contains(@class, ' glossentry/glossAcronym ')]/node()"/>
<xsl:variable name="glossdef" select="*[contains(@class, ' glossentry/glossdef ')]/node()"/>
<xsl:variable name="glossterm" select="*[contains(@class, ' glossentry/glossterm ')]/node()"/>


<fo:block xsl:use-attribute-sets="__glossary__entry">
<xsl:call-template name="commonattributes"/>
<fo:block>
<xsl:attribute name="id">
<xsl:call-template name="generate-toc-id"/>
</xsl:attribute>
<fo:block xsl:use-attribute-sets="__glossary__term">
<xsl:apply-templates select="$glossSynonym"/>
</fo:block>

<fo:block xsl:use-attribute-sets="__glossary__def">
<xsl:if test="$glossAcronym">
<xsl:apply-templates select="$glossterm"/>
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:apply-templates select="$glossdef"/>
</fo:block>
</fo:block>
</fo:block>


</xsl:template>
Thanks. I am still quite new to the web publishing side of building XSLTs.

Take care,
- Nick
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Webhelp XSLT glossentry override

Post by Radu »

Hi Nick,

Ideally you would avoid XSLT customization and use a custom CSS instead:

https://www.oxygenxml.com/doc/versions/ ... n-css.html

After the publishing is done you can open from the output folder the HTML document corresponding to your glossentry and look for @class attribute values, for example the glossentry title will be something like:

Code: Select all

<h1 class="title title glossterm topictitle1">some title</h1>
so you can match it from a custom CSS using a selector like:

Code: Select all


.glossterm{
....
}
As for the XSLT based approach, the XSLT stylesheet:

DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\dita2htmlImpl.xsl

has some generic processing for any type of topic (including glossentry):

Code: Select all

<xsl:template match="/dita | *[contains(@class, ' topic/topic ')]">
so I guess you could add more specific templates if you want to output glossentry in a special way.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
urbanrobots
Posts: 86
Joined: Sun May 03, 2015 7:34 pm
Location: San Francisco

Re: Webhelp XSLT glossentry override

Post by urbanrobots »

Hi Radu -

Okay, thanks. The CSS controls the styling, while the XSLT controls the structure, correct? I always look at CSS as formatting, similar to XSL attributes.

Can CSS change the structure of the glossary entry itself in output? We'd like to make glossSynonym the entryhead and not glossterm. This seems more like XSLT than CSS. Also, it doesn't seem like a CSS-only approach would allow us to hide certain elements from HTML output.

Take care,
- Nick
bogdan_cercelaru
Posts: 222
Joined: Tue Jul 01, 2014 11:48 am

Re: Webhelp XSLT glossentry override

Post by bogdan_cercelaru »

Hi Nick,

Yes, you are right, the CSS cannot change the structure of the generated HTML.
If you need to change the structure of the glossary entry, you need to modify the XSLT files. As Radu already said, take a look at the DITA-\OT/plugins\org.dita.xhtml\xsl\xslhtml\dita2htmlImpl.xsl file.

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
urbanrobots
Posts: 86
Joined: Sun May 03, 2015 7:34 pm
Location: San Francisco

Re: Webhelp XSLT glossentry override

Post by urbanrobots »

Thanks both!

Hi Bogdan,
Do you happen to know where the abbreviated-form is controlled for the left-hand navigation? We would like titles (in the topics and in the left-hand navigation) to always use the abbreviated-form. The left-hand navigation doesn't seem to follow the same templates as the main topics, for some reason.

Take care,
- Nick
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Webhelp XSLT glossentry override

Post by Radu »

Hi Nick,

WebHelp produced using Oxygen 17.1 should expand abbreviated forms in the table of contents titles.
The XSLT stylesheet:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT2.x\plugins\com.oxygenxml.webhelp\xsl\dita\tocDita.xsl

has a template like:

Code: Select all

  <xsl:template match="*[contains(@class, ' map/topicref ') 
and not(@processing-role='resource-only')
and not(@toc='no')
and not(ancestor::*[contains(@class, ' map/reltable ')])]"
mode="toc-webhelp">
.............
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aabuan123
Posts: 7
Joined: Tue Jun 25, 2019 10:30 pm

Re: Webhelp XSLT glossentry override

Post by aabuan123 »

Hi,

Thanks for this solution. I was able to use this to change the side-toc menu for my acronyms to just show the acronym instead of the glossterm.

But for the topic title I want to use the glossSurfaceForm as the title for the acronym topic instead of the glossterm. How do I do this? I can't seem to find the xsl to override for the topic title.

Thanks,
Alice
Post Reply