xref in Content to Bookmap TOC

Post here questions and problems related to editing and publishing DITA content.
patjporter
Posts: 53
Joined: Sat May 22, 2021 6:04 pm

xref in Content to Bookmap TOC

Post 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
image.png (30.24 KiB) Viewed 731 times
Thanks!
Pat
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: xref in Content to Bookmap TOC

Post 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
patjporter
Posts: 53
Joined: Sat May 22, 2021 6:04 pm

Re: xref in Content to Bookmap TOC

Post 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
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: xref in Content to Bookmap TOC

Post 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
Post Reply