Webhelp XSLT glossentry override

Here should go questions about transforming XML with XSLT and FOP.
urbanrobots
Posts: 79
Location: San Francisco

Webhelp XSLT glossentry override

Fri Mar 25, 2016 6:16 pm

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: 5226

Re: Webhelp XSLT glossentry override

Mon Mar 28, 2016 12:26 pm

Hi Nick,

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

https://www.oxygenxml.com/doc/versions/17.1/ug-editor/#topics/webhelp-customization-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: 79
Location: San Francisco

Re: Webhelp XSLT glossentry override

Sat Apr 02, 2016 8:43 pm

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: 196

Re: Webhelp XSLT glossentry override

Tue Apr 05, 2016 9:03 am

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: 79
Location: San Francisco

Re: Webhelp XSLT glossentry override

Tue Apr 12, 2016 7:26 pm

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: 5226

Re: Webhelp XSLT glossentry override

Thu Apr 14, 2016 4:09 pm

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

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest