Page 1 of 1

customizing for related topic output

Posted: Sat Feb 28, 2015 12:40 am
by mark_whisler
We're using oXygen 16.1 to develop a replacement help system using WebHelp output. In the default output, the topics are distributed by topic type, Related concepts, Related reference, Related tasks. Can you direct me to a way to aggregate all related topics under a single "Related topics" entry? Hopefully its just a setting I've missed in my perusal of the docs...

Thanks

.MW

Re: customizing for related topic output

Posted: Thu Mar 05, 2015 6:36 pm
by sorin_ristache
Some XSLT code modifications are necessary for that in the DITA transformation that generates the WebHelp pages. It is relatively easy to process all related links (links to concepts, links to tasks, links to glossary topics) in a general and uniform way, as generic topics, as if every section had the title Related information, and no section would had a title Related tasks or Related concepts. But that would still leave you with different sections (all having the same title: Related information). That would only require overriding three short XSLT templates (the ones for related tasks, related concepts and related references) and redirecting them to the processing for generic related topics.

Merging all related topics sections on a page into a single section of related links (the one called Related information) would require some more XSLT work. I can give you some pointers if you want to try this yourself.

Re: customizing for related topic output

Posted: Fri Mar 13, 2015 2:16 am
by mark_whisler
Yes please! Based on our current models, a single block of Related Information entries would seem to be preferable, and if I do it and my fellow writers hate it, I can always go back.

Re: customizing for related topic output

Posted: Fri Mar 13, 2015 11:29 am
by sorin_ristache
The sections with the titles Related tasks, Related concepts and Related references are XHTML <div> elements created by the following XSLT templates:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/link ')][@type='task']" mode="related-links:result-group" name="related-links:result.task">

Code: Select all

<xsl:template match="*[contains(@class, ' topic/link ')][@type='concept']" mode="related-links:result-group" name="related-links:result.concept">

Code: Select all

<xsl:template match="*[contains(@class, ' topic/link ')][@type='reference']" mode="related-links:result-group" name="related-links:result.reference">
which are located in the XSLT files:

Code: Select all

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\taskdisplay.xsl

Code: Select all

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\conceptdisplay.xsl

Code: Select all

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\refdisplay.xsl
I suggest finding where these three XSLT templates are called from and merging them so that only one common section (only one <div> element) is created in an XHTML output page instead of one distinct section (one distinct <div> element) per type of related links (one section with the links to tasks, one section with the links to concepts, one section with the links to generic topics, etc).

Re: customizing for related topic output

Posted: Fri Apr 01, 2016 9:08 am
by urbanrobots
Outside of XSLT, you can use @type = "topic" in the DITA source reltable to override the concept, reference task organization. By specifying topic, all links are organized under a "Related information" heading.

Take care,
-Nick

Re: customizing for related topic output

Posted: Thu May 18, 2017 6:30 pm
by rdelong
We had the same requirement to list all related links under the same heading. Here's what I did to create the desired results. I only spent a couple of hours on this, so I'm sure this method can be improved upon by more expert XSLT developers.

I created a new rel-links.myplugin.xsl file with the following templates:

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/link ')]" name="topic.link">
<xsl:if test="(@role and contains($include.roles, concat(' ', @role, ' '))) or
(not(@role) and contains($include.roles, ' #default '))">
<xsl:choose>
<!-- Linklist links put out <br/> in "processlinklist" -->
<xsl:when test="ancestor::*[contains(@class,' topic/linklist ')]">
<xsl:call-template name="makelink"/>
</xsl:when>
<!-- Ancestor links go in the breadcrumb trail, and should not get a <br/> -->
<xsl:when test="@role='ancestor'">
<xsl:call-template name="makelink"/>
</xsl:when>
<!-- Items with these roles should always go to output, and are not included in the hideduplicates key. -->
<xsl:when test="@role and not(@role='cousin' or @role='external' or @role='friend' or @role='other' or @role='sample' or @role='sibling')">
<div><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/>
</xsl:when>
<!-- If roles do not match, but nearly everything else does, skip the link. -->
<xsl:when test="(key('hideduplicates', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*))))[2]">
<xsl:choose>
<xsl:when test="generate-id(.)=generate-id((key('hideduplicates', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*))))[1])">
<div class="relinfo"><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/>
</xsl:when>
<!-- If this is filtered out, we may need the duplicate link message anyway. -->
<xsl:otherwise><xsl:call-template name="linkdupinfo"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><div class="relinfo"><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/></xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>

<!-- Combine all related links into a single, Related information, list. -->
<xsl:template match="*[contains(@class, ' topic/link ')]" mode="related-links:result-group">
<xsl:param name="links"/>
<xsl:copy-of select="$links"/>
</xsl:template>
This code lists the links within a single <div class="related-links">, but I couldn't figure out how print the Related information title at the start of the list. So, I relied on CSS to do the trick:

Code: Select all


.related-links:before {
font-family:"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 18px;
font-weight: bold;
margin-top: 18px;
margin-bottom: 0px;
content: "Related information:"; }
.relinfo { margin-top: .1em; margin-bottom: .1em; font-style: italic; }