Subject: [xsl] Duplicate title issue From: "J.S. Rawat jogarawat@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 9 Apr 2025 12:56:14 -0000 |
Hi Team, I am facing duplicate topicref problem. Please help. Output <map id="d1e1" xml:lang="en-us"> <title>1.0 Electrical</title> <topicref1 navtitle="1.0 Electrical" href="electrical.dita"> <topicref4 navtitle="1.1 Wire" href="wire.dita"/> <topicref2 navtitle="1.2 Switches" href="switches.dita"> <topicref4 navtitle="1.2.1 Switch type" href="switch_type.dita"/> <topicref4 navtitle="1.2.2 How connected" href="how_th.dita"/> <topicref4 navtitle="1.2.3 Switch operates" href="how_the.dita"/> <topicref4 navtitle="1.2.4 Function" href="function.dita"/> <topicref2 navtitle="1.3 Specialty switches" href="specialty_switches.dita"/> </topicref2> <topicref4 navtitle="1.2.1 Switch type" href="switch_type.dita"/> <topicref4 navtitle="1.2.2 How connected" href="how_th.dita"/> <topicref4 navtitle="1.2.3 Switch operates" href="how_the.dita"/> <topicref4 navtitle="1.2.4 Function" href="function.dita"/> <topicref2 navtitle="1.3 Specialty switches" href="specialty_switches.dita"/> </topicref1> <topicref1 navtitle="2.0 Switch symbols (Switcheally)" href="switch.dita"/> </map> Exptected Output <map id="d1e1" xml:lang="en-us"> <title>1.0 Electrical</title> <topicref1 navtitle="1.0 Electrical" href="electrical.dita"> <topicref2 navtitle="1.1 Wire" href="wire.dita"/> <topicref2 navtitle="1.2 Switches" href="switches.dita"> <topicref4 navtitle="1.2.1 Switch type" href="switch_type.dita"/> <topicref4 navtitle="1.2.2 How connected" href="how_th.dita"/> <topicref4 navtitle="1.2.3 Switch operates" href="how_the.dita"/> <topicref4 navtitle="1.2.4 Function" href="function.dita"/> </topicref2 <topicref2 navtitle="1.3 Specialty switches" href="specialty_switches.dita"/> </topicref1> <topicref1 navtitle="2.0 Switch symbols (Switcheally)" href="switch.dita"/> </map> xslt <!--to Generate chapter TOC and filename will be .ditamap--> <xsl:template match="topics"> <xsl:variable name="folder-name"><xsl:value-of select="@folder"/></xsl:variable> <xsl:variable name="title"><xsl:value-of select="translate(topic[1]/title, ' - ', '_')"/></xsl:variable> <xsl:variable name="topicName" select="lower-case(translate($title, ' ,.()?[]&b":/%#', '_'))"/> <xsl:result-document href="argos-dita/{$folder-name}/m_{$topicName}.ditamap" method="xml"> <map id="{generate-id()}" xml:lang="en-us"> <title> <xsl:value-of select="topic[1]/title"/> </title> <xsl:for-each select="topic[@type = '1']"> <xsl:variable name="subsection" select="@filename"/> <topicref1 href="{$subsection}.dita" navtitle="{title}"> <xsl:if test="body[not(child::*)]"> <xsl:attribute name="topichead">yes</xsl:attribute> </xsl:if> <xsl:if test="following-sibling::*[1][self::topic[@type = '2']] or following-sibling::*[1][self::topic[@type = '3']] or following-sibling::*[1][self::topic[@type = '4']]"> <xsl:call-template name="pullObjects"/> </xsl:if> </topicref1> </xsl:for-each> <xsl:call-template name="pullObjects"/> </map> </xsl:result-document> </xsl:template> <xsl:template match="topic[@type='2']" mode="pullObjects"> <xsl:variable name="subsection" select="@filename"/> <topicref2 navtitle="{title}" href="{$subsection}.dita"> <xsl:if test="body[not(child::*)]"> <xsl:attribute name="topichead">yes</xsl:attribute> </xsl:if> <xsl:if test="following-sibling::*[1][self::topic[@type = '3']] or following-sibling::*[1][self::topic[@type = '4']]"> <xsl:call-template name="pullObjects"/> </xsl:if> </topicref2> <xsl:call-template name="pullObjects"/> </xsl:template> <xsl:template match="topic[@type='3']" mode="pullObjects"> <xsl:variable name="subsection" select="@filename"/> <topicref4 navtitle="{title}" href="{$subsection}.dita"> <xsl:if test="body[not(child::*)]"> <xsl:attribute name="topichead">yes</xsl:attribute> </xsl:if> <xsl:if test="following-sibling::*[1][self::topic[@type = '4']] or following-sibling::*[1][self::topic[@type = '5']]"> <xsl:call-template name="pullObjects"/> </xsl:if> </topicref4> <xsl:call-template name="pullObjects"/> </xsl:template> <xsl:template match="topic[@type='4']" mode="pullObjects"> <xsl:variable name="subsection" select="@filename"/> <topicref4 navtitle="{title}" href="{$subsection}.dita"> <xsl:if test="body[not(child::*)]"> <xsl:attribute name="topichead">yes</xsl:attribute> </xsl:if> </topicref4> <xsl:call-template name="pullObjects"/> </xsl:template> <xsl:template name="pullObjects"> <xsl:apply-templates select="following-sibling::*[1][self::topic[@type='2'] or self::topic[@type='3'] or self::topic[@type='4']]" mode="pullObjects"/> </xsl:template> thanks ...JSR
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Indirect referencing in X, Liam R. E. Quin liam | Thread | Re: [xsl] Duplicate title issue, J.S. Rawat jogarawat |
Re: [xsl] Indirect referencing in X, Liam R. E. Quin liam | Date | [xsl] Pointers are weird, Roger L Costello cos |
Month |