Change format of section contents in WebHelp

Post here questions and problems related to editing and publishing DITA content.
Lachlan_Murray
Posts: 9
Joined: Fri Oct 31, 2014 12:15 am

Change format of section contents in WebHelp

Post by Lachlan_Murray »

Hi,

I want to change the way the automatically generated section contents in WebHelp is output from the DITA OT (Oxygen 16.0). I'm referring to the section-level contents that appear at the bottom of a section parent page.

Currently, the default format, including the bolding, looks like this:

• Child Topic 1
• Child Topic 2
• Child Topic 3


I want the section contents to look exactly like the default "Related concepts", "Related tasks", and "Related information" lists of links. So, like this, without bullets, with a "Section contents" heading, and with bolding on the "Section contents" heading only:

Section contents
Child Topic 1
Child Topic 2
Child Topic 3

I'm assuming this means an XSL and a CSS change. Any help you can provide would be appreciated.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Change format of section contents in WebHelp

Post by sorin_ristache »

Hi,

I am not sure what you mean by the child topics of a section. The section element does not allow a topic child element. Do you mean the list of child links at the bottom of a topic page? Is yes, for modifying the list of child links please add the following template to the stylesheet OXYGEN_DIR\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\dita2webhelp.xsl, which you can further modify as needed:

Code: Select all

    <xsl:template name="ul-child-links">
<xsl:if test="descendant::*[contains(@class, ' topic/link ')][@role='child' or @role='descendant'][not(parent::*/@collection-type='sequence')][not(ancestor::*[contains(@class, ' topic/linklist ')])]">
<xsl:value-of select="$newline"/>
<strong>
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'Section contents'"/>
</xsl:call-template>
</strong>
<ul class="ullinks">
<xsl:value-of select="$newline"/>
<!--once you've tested that at least one child/descendant exists, apply templates to only the unique ones-->
<xsl:apply-templates select="descendant::*
[generate-id(.)=generate-id(key('link',concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,child::*))[1])]
[contains(@class, ' topic/link ')]
[@role='child' or @role='descendant']
[not(parent::*/@collection-type='sequence')]
[not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
</ul><xsl:value-of select="$newline"/>
</xsl:if>
</xsl:template>
and also add the following line in the file OXYGEN_DIR\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\oxygen-webhelp\resources\localization\strings-en-us.xml;

Code: Select all

  <str name="Section contents">Section contents</str>
This template with the name="ul-child-links" attribute creates the list of links to the child topics which you wanted to modify, so this is the XSLT code that you have to modify if you want to modify the look of this list.
Regards,
Sorin

<oXygen/> XML Editor Support
Lachlan_Murray
Posts: 9
Joined: Fri Oct 31, 2014 12:15 am

Re: Change format of section contents in WebHelp

Post by Lachlan_Murray »

Hi Sorin,

Sorry for the confusion. I'm not referring to the DITA section element, but rather a generic "section" in the WebHelp system -- i.e., a parent topic with a number of child topics nested beneath it. I think you got my meaning. So, yes, as you say, the "list of child links at the bottom of a topic page" is what I want to format differently.

I added your code to the two files but unfortunately the transformation fails. Here's the error message:

Code: Select all

System ID: C:\Program Files\Oxygen XML Editor 16\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\dita2webhelp.xsl
Scenario: DITA Map WebHelp - Copy
Input file: C:\TechPubs_int\techpubsvob\dita\ACL Analytics 11\acl_analytics_help_system_Oxy.ditamap
Engine name: DITA-OT
Severity: fatal
Description: A sequence of more than one item is not allowed as the 18th argument of concat()
Start location: 268:0
When I click on the error message, it highlights this line in dita2webhelp.xsl in the template you provided:

Code: Select all

[not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
Lachlan
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Change format of section contents in WebHelp

Post by sorin_ristache »

Hi Lachlan,

The xsl:apply-templates XPath expression must be corrected because it is used in an XSLT 2.0 stylesheet (it was borrowed from an XSLT 1.0 stylesheet so it needs a minor modification to make it fully compatible). Please replace the xsl:apply-templates element with the following improved version:

Code: Select all

<xsl:apply-templates select="descendant::*
[generate-id(.)=generate-id(key('link',concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,child::*[1]))[1])]
[contains(@class, ' topic/link ')]
[@role='child' or @role='descendant']
[not(parent::*/@collection-type='sequence')]
[not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
Regards,
Sorin

<oXygen/> XML Editor Support
Post Reply