How to change default behavior of webhelp output that tests

Post here questions and problems related to editing and publishing DITA content.
mstrubberg
Posts: 48
Joined: Sat Jan 26, 2013 6:07 pm

How to change default behavior of webhelp output that tests

Post by mstrubberg »

When entering any type of list <ol>, <ul>, <dl>, <sl>, <choices> the compact attribute value is not set in the XML.

However, webhelp output is defaulting all lists to compact="yes", thereby compressing the list items together.

I don't want to require that all lists must have compact="no" applied.

What is the best way to default all lists to compact="no"?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to change default behavior of webhelp output that te

Post by sorin_ristache »

The default value of the compact attribute in DITA XML topics is yes for ordered lists, unordered lists, etc. So if you want to have a larger space between list items the usual way is to add the compact="no" attribute on the XML list elements.

Other option that would follow the DITA spirit is to extend the DITA schema and create a DITA specialization that sets the compact attribute to the value that you want on the XML elements that you want.

A more expedient option is to do the following changes in the file OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\dita2htmlImpl.xsl:
  • 1. Replace the code:

    Code: Select all

    <xsl:template match="*[contains(@class, ' topic/li ')]" name="topic.li">
    <li>
    <xsl:choose>
    <xsl:when test="parent::*/@compact = 'no'">
    <xsl:attribute name="class">liexpand</xsl:attribute>
    <!-- handle non-compact list items -->
    <xsl:call-template name="commonattributes">
    <xsl:with-param name="default-output-class" select="'liexpand'"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="commonattributes"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:call-template name="setidaname"/>
    <xsl:apply-templates/>
    </li><xsl:value-of select="$newline"/>
    </xsl:template>
    with the code:

    Code: Select all

    <xsl:template match="*[contains(@class, ' topic/li ')]" name="topic.li">
    <li>
    <xsl:attribute name="class">liexpand</xsl:attribute>
    <!-- handle non-compact list items -->
    <xsl:call-template name="commonattributes">
    <xsl:with-param name="default-output-class" select="'liexpand'"/>
    </xsl:call-template>
    <xsl:call-template name="setidaname"/>
    <xsl:apply-templates/>
    </li><xsl:value-of select="$newline"/>
    </xsl:template>

    2. Replace the code:

    Code: Select all

    <xsl:template match="*[contains(@class, ' topic/sli ')]" name="topic.sli">
    <li>
    <xsl:choose>
    <xsl:when test="parent::*/@compact = 'no'">
    <xsl:attribute name="class">sliexpand</xsl:attribute>
    <!-- handle non-compact list items -->
    <xsl:call-template name="commonattributes">
    <xsl:with-param name="default-output-class" select="'sliexpand'"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="commonattributes"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:call-template name="commonattributes"/>
    <xsl:call-template name="setidaname"/>
    <xsl:apply-templates/>
    </li><xsl:value-of select="$newline"/>
    </xsl:template>
    with the code:

    Code: Select all

    <xsl:template match="*[contains(@class, ' topic/sli ')]" name="topic.sli">
    <li>
    <xsl:attribute name="class">sliexpand</xsl:attribute>
    <!-- handle non-compact list items -->
    <xsl:call-template name="commonattributes">
    <xsl:with-param name="default-output-class" select="'sliexpand'"/>
    </xsl:call-template>
    <xsl:call-template name="commonattributes"/>
    <xsl:call-template name="setidaname"/>
    <xsl:apply-templates/>
    </li><xsl:value-of select="$newline"/>
    </xsl:template>
Regards,
Sorin

<oXygen/> XML Editor Support
mstrubberg
Posts: 48
Joined: Sat Jan 26, 2013 6:07 pm

Re: How to change default behavior of webhelp output that te

Post by mstrubberg »

Thanks Sorin, Removing the test for compact='no' worked perfectly.
Post Reply