Issue with copy-to on sub-topics with locktitles

axhxu
Posts: 30
Joined: Thu Aug 27, 2015 9:28 pm

Issue with copy-to on sub-topics with locktitles

Post by axhxu » Fri Oct 04, 2019 3:40 pm

The topic should use the navtitle defined in the map when @locktitle=yes.

Instead topic is using the title of the first instance of the topic when topic is referenced as a sub-topic.

Note: @copy-to and @locktitle works when used at the same level as the original topic.

Sample map:

Code: Select all

<topicref class="- map/topicref " ixia_locid="5" keys="axk1425415118966"
    href="axk1425415118966.xml" type="task">
    <topicmeta class="- map/topicmeta ">
        <navtitle class="- topic/navtitle " ixia_locid="7">Performing reading tasks</navtitle>
        <linktext class="- map/linktext " ixia_locid="8">Performing reading tasks</linktext>
        <shortdesc class="- map/shortdesc ">Whether dictating with online speech recognition,
            digital dictation, or typing reports, you report on studies by way of reading tasks.
            A single reading task can contain one or more studies for which you create a single
            report.</shortdesc>
    </topicmeta>
</topicref>
<topicref class="- map/topicref " copy-to="second-axk1425415118966.xml" ixia_locid="11"
    keys="second-axk1425415118966" locktitle="yes" href="axk1425415118966.xml" type="task">
    <topicmeta class="- map/topicmeta ">
        <navtitle class="- topic/navtitle " ixia_locid="12">Arron Testing Copy-to and
            Locktitle</navtitle>
        <linktext class="- map/linktext " ixia_locid="13">Arron Testing Copy-to and
            Locktitle</linktext>
        <shortdesc class="- map/shortdesc ">Whether dictating with online speech recognition,
            digital dictation, or typing reports, you report on studies by way of reading tasks.
            A single reading task can contain one or more studies for which you create a single
            report.</shortdesc>
    </topicmeta>
    <topicref class="- map/topicref " copy-to="third-axk1425415118966.xml" ixia_locid="14"
        keys="third-axk1425415118966" locktitle="yes" href="axk1425415118966.xml" type="task">
        <topicmeta class="- map/topicmeta ">
            <navtitle class="- topic/navtitle ">Arron 2 Testing Copy-to and
                Locktitle</navtitle>
            <linktext class="- map/linktext " ixia_locid="16">Arron 2 Testing Copy-to and
                Locktitle</linktext>
            <shortdesc class="- map/shortdesc ">Whether dictating with online speech
                recognition, digital dictation, or typing reports, you report on studies by way
                of reading tasks. A single reading task can contain one or more studies for
                which you create a single report.</shortdesc>
        </topicmeta>
    </topicref>
</topicref>
<topicref class="- map/topicref " copy-to="fourth-axk1425415118966.xml" ixia_locid="14"
    keys="fourth-axk1425415118966" locktitle="yes" href="axk1425415118966.xml" type="task">
    <topicmeta class="- map/topicmeta ">
        <navtitle class="- topic/navtitle ">Arron 3 Testing Copy-to and
            Locktitle</navtitle>
        <linktext class="- map/linktext " ixia_locid="16">Arron 3 Testing Copy-to and
            Locktitle</linktext>
        <shortdesc class="- map/shortdesc ">Whether dictating with online speech
            recognition, digital dictation, or typing reports, you report on studies by way
            of reading tasks. A single reading task can contain one or more studies for
            which you create a single report.</shortdesc>
    </topicmeta>
</topicref>
Is this a bug or something we are doing wrong?

Thanks
Arron

radu_pisoi
Posts: 352
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Issue with copy-to on sub-topics with locktitles

Post by radu_pisoi » Wed Oct 09, 2019 12:04 pm

Hi,

I rather think this bug is related with the DITA-OT publishing engine where you have already recorded an issue:
https://github.com/dita-ot/dita-ot/issues/3372

As workaround, it seems you can remove the locktitle attribute from sub-topics, case when the value from parent element is used.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

axhxu
Posts: 30
Joined: Thu Aug 27, 2015 9:28 pm

Re: Issue with copy-to on sub-topics with locktitles

Post by axhxu » Fri Oct 18, 2019 2:55 pm

Thanks.

I checked the code and <linktext> retains the the correct title.

Could I override the toc processing to use <linktext> instead of <navtitle> if @locktitle=yes?

Code: Select all

<navtitle class="- topic/navtitle ">Performing reading tasks</navtitle>
                <?ditaot usertext?>
                <linktext class="- map/linktext " ixia_locid="16" xtrc="linktext:3;38:67"
                    xtrf="file:/D:/Users/axhxu/Desktop/testing/postprocessed.IPTS-1294/axh1430149607893.ditamap"
                    >Arron 2 Testing Copy-to and Locktitle</linktext>

radu_pisoi
Posts: 352
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Issue with copy-to on sub-topics with locktitles

Post by radu_pisoi » Tue Oct 22, 2019 11:11 am

Hi,

Please note that the linktext element is intended to be used only when the target cannot be reached, such as when it is a peer or external link, or when the target is local but not in DITA format. See more details in DITA specs [1].

However, if you want to override the toc processing you can use the com.oxygenxml.webhelp.xsl.createTocXML[2] XSLT-Import extension point. This extension point allows you to override the XSLT stylesheet (tocDita.xsl) that produces the toc.xml file. This file contains information extracted from the DITA map and it is mainly used to construct the WebHelp Table of Contents and navigational links.

[1] - https://www.oxygenxml.com/dita/1.3/spec ... ktext.html
[2] - https://www.oxygenxml.com/doc/versions/ ... uyr_b1y_bx
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

axhxu
Posts: 30
Joined: Thu Aug 27, 2015 9:28 pm

Re: Issue with copy-to on sub-topics with locktitles

Post by axhxu » Wed Oct 23, 2019 8:53 pm

Ok I created a customTocXML.xsl file and added the extension point to my opt file.

Problem is my titles are blank.

Here is my customTocXML.xsl:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:relpath="http://dita2indesign/functions/relpath"
    xmlns:oxygen="http://www.oxygenxml.com/functions"
    xmlns:toc="http://www.oxygenxml.com/ns/webhelp/toc"
    xmlns="http://www.oxygenxml.com/ns/webhelp/toc" exclude-result-prefixes="relpath oxygen"
    xmlns:xhtml="http://www.w3.org/1999/xhtml" version="2.0">
    
    <xsl:output method="xml" encoding="UTF-8" indent="no"/>
    
    <xsl:template
        match="
        *[contains(@class, ' map/topicref ')
        and(@locktitle='yes')
        and(@copy-to)
        and not(@processing-role = 'resource-only')
        and not(@toc = 'no')
        and not(ancestor::*[contains(@class, ' map/reltable ')])]"
        mode="toc-webhelp">
        
        <xsl:variable name="title" as="node()*">
            <xsl:variable name="navTitleElem" >
               
                  <xsl:value-of select="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]"/>
               
            </xsl:variable>
            <xsl:choose>
                <xsl:when test="$navTitleElem">
                    <!-- Fix the href attribute in the navtitle -->
                    <xsl:variable name="navTitle_hrefFixed">
                        <xsl:apply-templates select="$navTitleElem" mode="fixHRef">
                            <xsl:with-param name="base-uri" select="base-uri()"/>
                        </xsl:apply-templates>/ </xsl:variable>
                    
                    <xsl:apply-templates select="$navTitle_hrefFixed/*/node()"/>
                    <!--<xsl:apply-templates select="$navTitleElem/node()"/>-->
                </xsl:when>
                <xsl:when test="@navtitle">
                    <xsl:value-of select="@navtitle"/>
                </xsl:when>
            </xsl:choose>
        </xsl:variable>
        
        <xsl:choose>
            <xsl:when test="@href or @copy-to or not(empty($title))">
                <topic>
                    <xsl:attribute name="href">
                        <xsl:choose>
                            <xsl:when
                                test="@copy-to and not(ancestor-or-self::*[contains(@chunk, 'to-content')])">
                                <xsl:call-template name="replace-extension">
                                    <xsl:with-param name="filename" select="@copy-to"/>
                                    <xsl:with-param name="extension" select="$OUT_EXT"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="@href">
                                <xsl:call-template name="replace-extension">
                                    <xsl:with-param name="filename" select="@href"/>
                                    <xsl:with-param name="extension" select="$OUT_EXT"/>
                                    <xsl:with-param name="forceReplace"
                                        select="not(@format) or @format = 'dita'"/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$VOID_HREF"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:attribute>
                    
                    <xsl:if test="@collection-type">
                        <xsl:attribute name="collection-type" select="@collection-type"/>
                    </xsl:if>
                    <xsl:if test="@outputclass">
                        <xsl:attribute name="outputclass" select="@outputclass"/>
                    </xsl:if>
                    <xsl:if test="@scope and not(@scope = 'local')">
                        <xsl:attribute name="scope" select="@scope"/>
                    </xsl:if>
                    <!-- WH-257: Copy "chunk" info. -->
                    <xsl:copy-of select="@chunk"/>
                    <!-- WH-257: Copy "format" attribute. -->
                    <xsl:copy-of select="@format"/>
                    
                    <xsl:if test="exists($passthrough-attrs)">
                        <xsl:for-each select="@*">
                            <xsl:if
                                test="
                                $passthrough-attrs[@att = name(current()) and (empty(@val) or (some $v in tokenize(current(), '\s+')
                                satisfies $v = @val))]">
                                <xsl:attribute name="data-{name()}" select="."/>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    
                    <xsl:variable name="topicId">
                        <xsl:choose>
                            <!-- Pickup the ID from the topic file, that was set in the topicmeta by a previous processing (see "addResourceID.xsl").  -->
                            <xsl:when test="*[contains(@class, ' map/topicmeta ')]/@data-topic-id">
                                <xsl:value-of
                                    select="*[contains(@class, ' map/topicmeta ')]/@data-topic-id"/>
                            </xsl:when>
                            <!-- Fallback to the ID set on the topicref. For instance the topichead does not point to a topic 
                                file (that would have an ID inside), but can have an ID set on it directly in the map.-->
                            <xsl:when test="@id">
                                <xsl:value-of select="@id"/>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:variable>
                    
                    <xsl:if test="string-length($topicId) > 0">
                        <xsl:attribute name="data-id" select="$topicId"/>
                    </xsl:if>
                    
                    <xsl:attribute name="wh-toc-id">
                        <xsl:variable name="tocIdPrefix">
                            <xsl:choose>
                                <xsl:when test="string-length($topicId) > 0">
                                    <xsl:value-of select="$topicId"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="'tocId'"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:variable>
                        <xsl:value-of select="concat($tocIdPrefix, '-', generate-id(.))"/>
                    </xsl:attribute>
                    
                    <title>
                        <xsl:choose>
                            <xsl:when test="not(empty($title))">
                                <xsl:copy-of select="$title"/>
                            </xsl:when>
                            <xsl:otherwise>Arron</xsl:otherwise>
                        </xsl:choose>
                    </title>
                    
                    <xsl:variable name="shortDesc"
                        select="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/shortdesc ')][1]"/>
                    <xsl:if test="$shortDesc">
                        <xsl:variable name="shortDesc_hrefFixed">
                            <xsl:apply-templates select="$shortDesc" mode="fixHRef">
                                <xsl:with-param name="base-uri" select="base-uri()"/>
                            </xsl:apply-templates>
                        </xsl:variable>
                        
                        <shortdesc>
                            <xsl:apply-templates select="$shortDesc_hrefFixed/node()"/>
                        </shortdesc>
                    </xsl:if>
                    <xsl:apply-templates select="*[contains(@class, ' map/topicmeta ')]"
                        mode="copy-topic-meta"/>
                    <xsl:apply-templates mode="toc-webhelp"/>
                </topic>
            </xsl:when>
            <xsl:otherwise>
                <!-- Do not contribute a level in the TOC, but recurse in the child topicrefs -->
                <xsl:apply-templates mode="toc-webhelp"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
</xsl:stylesheet>

axhxu
Posts: 30
Joined: Thu Aug 27, 2015 9:28 pm

Re: Issue with copy-to on sub-topics with locktitles

Post by axhxu » Fri Oct 25, 2019 4:36 pm

Found the issue...I just had to change the navTitleElem to

Code: Select all

 <xsl:variable name="navTitleElem" select="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]"/>

Post Reply