Apply a specific attribute only on chunked topics
Posted: Sat Dec 17, 2022 5:24 pm
Hello,
I'm currently having difficulties with a transformation in a plugin whose purpose is to apply a custom attribute to chunked topics.
Concretely, I have topicrefs with chunked topics in a map that contains an outputclass that will serve for the transformation:
My transformation should chunk these topics together. Thanks to an XSL, I will use the tabbed-title outputclass to be transformed into another attribute name.
Everything works fine except that the top div with the class "globalTopic" will also receive the attribute data-ft-tab-label whereas I try to apply only to the nested topics.
Currently, the HTML source displays for the parent topic this:
By any chance, do you have any suggestion?
I'm currently having difficulties with a transformation in a plugin whose purpose is to apply a custom attribute to chunked topics.
Concretely, I have topicrefs with chunked topics in a map that contains an outputclass that will serve for the transformation:
Code: Select all
<topicref href="colors/t_introduction.dita" chunk="to-content">
<topicref href="colors/t_orange.dita" outputclass="tabbed-title=Orange"/>
<topicref href="colors/t_green.dita" outputclass="tabbed-title=Green"/>
<topicref href="colors/t_gray.dita" outputclass="tabbed-title=Gray"/>
<topicref href="colors/t_black.dita" outputclass="tabbed-title=Black"/>
</topicref>
Code: Select all
<xsl:template match="*[contains(@class, ' topic/topic ')]" mode="child.topic" name="child.topic">
<xsl:param name="nestlevel" as="xs:integer">
<xsl:choose>
<!-- Limit depth for historical reasons, could allow any depth. Previously limit was 5. -->
<xsl:when test="count(ancestor::*[contains(@class, ' topic/topic ')]) > 9"
>9</xsl:when>
<xsl:otherwise>
<xsl:sequence select="count(ancestor::*[contains(@class, ' topic/topic ')])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:variable name="topic_id" select="@id"/>
<xsl:variable name="attributeValue">
<xsl:value-of select="$mapDoc//topicref[contains(@href, $topic_id)]/@outputclass"/>
</xsl:variable>
<article class="globalTopic">
<xsl:variable name="apos">'</xsl:variable>
<xsl:if test="contains($attributeValue, 'tabbed-title=')">
<xsl:attribute name="data-ft-tab-label">
<xsl:value-of select="substring-after(translate($attributeValue, $apos, ''),'=')"/>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="gen-topic">
<xsl:with-param name="nestlevel" select="$nestlevel"/>
</xsl:call-template>
</article>
</xsl:template>
Currently, the HTML source displays for the parent topic this:
Code: Select all
<div class="globalTopic" aria-labelledby="ariaid-title1" data-ft-tab-label="Orange tabbed-title=Green tabbed-title=Gray tabbed-title=Black">
....
<div class="topic nested1" aria-labelledby="ariaid-title2" data-ft-tab-label="Orange" id="t_orange">...</div>
<div class="topic nested1" aria-labelledby="ariaid-title3" data-ft-tab-label="Green" id="t_green">...</div>
</div>