Template creates an empty div

rdelong
Posts: 49

Template creates an empty div

Fri Dec 01, 2017 8:23 pm

We have an xsl:template in our WebHelp plugin that places all of the <info> content within a collapsible div. We designed this template so that any cautions and Important Notes are outside of the collapsible div. What the developer of this XSLT neglected to code is if the <info> tag contains only cautions and Important Notes then the results would be an empty div. The developer is long gone so I need to fix it, but I'm not sure how to approach this.

Here's our code:

Code: Select all

<xsl:template match="*[contains(@class,' task/info ')]|*[contains(@otherprops, 'enable_moreinfo')]|*[contains(@otherprops, 'disable_moreinfo')]" name="topic.task.info">
        <xsl:choose>
            <xsl:when test="contains(@otherprops, 'disable_moreinfo')">
                <xsl:apply-templates select="*[contains(@type,'caution') or contains(@type,'important')]"/>
                <xsl:call-template name="generateItemGroupTaskElement"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="*[contains(@type,'caution') or contains(@type,'important')]"/>
                <div data-role="collapsible" data-collapsed="true" data-mini="true" data-theme="c" style="border:1pt solid red">
                    <h2>More Information:</h2>
                    <xsl:call-template name="generateItemGroupTaskElement"/>
                </div>               
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="generateItemGroupTaskElement">
        <div>
            <xsl:call-template name="commonattributes"/>
            <xsl:call-template name="setidaname"/>
            <xsl:apply-templates
                select="*[not(contains(@type,'important')) and not(contains(@type,'caution'))]|text()"/>
        </div>
    </xsl:template>

Return to “DITA (Editing and Publishing DITA Content)”

Who is online

Users browsing this forum: No registered users and 0 guests