Page 1 of 1

xref in Content to Bookmap TOC

Posted: Thu Jul 21, 2022 10:40 pm
by patjporter
Hello,
I am trying to place an xref inside each topic in my bookmap that will take me back to the Table of Contents. Unfortunately the TOC is a generated file, and there does not seem to be an href that I can construct like I normally would. Is there a way to put some kind of cross reference in each topics source XML to link back to the TOC?

image.png
Thanks!
Pat

Re: xref in Content to Bookmap TOC

Posted: Fri Jul 22, 2022 12:33 pm
by alex_jitianu
Hello,

In PDF you have a bookmarks panel and in WebHelp you have links on top of the pages. Why do you need an additional link to the toc in the topic?

Best regards,
Alex

Re: xref in Content to Bookmap TOC

Posted: Fri Jul 22, 2022 2:18 pm
by patjporter
Hi Alex,
Good question...we want to use this document on an iPad in an airplane, and it is easier to click a link on the page that you are on rather than select the bookmarks tab.
Is there a way to do this?
Thanks!
Pat

Re: xref in Content to Bookmap TOC

Posted: Tue Jul 26, 2022 10:36 am
by julien_lacour
Hi Pat,

This is possible in the DITA Map PDF - based on HTML5 & CSS transformation scenario by doing the following steps:
  1. Create an XSLT stylesheet with the following template:

    Code: Select all

    <xsl:template match="*[contains(@class, 'toc/title')]" mode="div-it">
      <div>
        <xsl:attribute name="class" select="'- toc/anchor anchor'"/>
        <xsl:attribute name="id" select="'toc-anchor'"/>
      </div>
      <xsl:next-match/>
    </xsl:template>
    
  2. Create a CSS stylesheet with the following template:

    Code: Select all

    @page chapter:first:left:right {
      @top-right {
        content: "Back to top";
        -oxy-link: "#toc-anchor";
        color: #337ab7;
      }
    }
    @page chapter:left:right {
      @top-right {
        content: "Back to top";
        -oxy-link: "#toc-anchor";
        color: #337ab7;
      }
    }
    
  3. Create a publishing template descriptor file (.opt) with the following elements:

    Code: Select all

    <resources>
      <css file="custom.css"/>
    </resources>
    ...
    <xslt>
      <extension file="m2h-link-to-toc.xsl" id="com.oxygenxml.pdf.css.xsl.merged2html5"/>
    </xslt>
    
If you need more detailed information, you can find it in our user guide there are other examples but they work in a similar way.

Regards,
Julien