Page 1 of 1

Book title in bookmarks as first top level element

Posted: Wed Nov 18, 2015 6:52 pm
by josecotes
Hi there,

How do I add the book title (from a bookmap/ditamap) as the main first element in my bookmark?

This is how it looks like now:

Code: Select all


- Chapter 1
- Content xxxx
- Content xxxx
- Chapter 2
- Content xxxx
- Content xxxx
- Content xxxx
- Chapter 3

This is what I am intending on achieving:

Code: Select all

Book title
- Chapter 1
- Content xxxx
- Content xxxx
- Chapter 2
- Content xxxx
- Content xxxx
- Content xxxx
- Chapter 3
Thanks for your help.

Re: Book title in bookmarks as first top level element

Posted: Fri Nov 20, 2015 2:59 pm
by radu_pisoi
Hi,

I assume that you want to change the bookmarks' structure for the DITA-OT PDF output.

DITA Open Toolkit PDF output can be customized in several ways:
* creating a DITA Open Toolkit plugin which adds extensions to the PDF plugin.
* creating a customization directory and using it from the PDF transformation scenario.

You can find more details in our user manual:
https://www.oxygenxml.com/doc/versions/ ... ation.html

For your request, you can follow the next procedure. This customization is based on the 'Custom directory' method. I've tested with DITA-OT 1.8.5.
* Copy the entire directory: DITA_OT_DIR\plugins\org.dita.pdf2\Customization to another location (for instance, C:\Customization).
* Rename C:\Customization\catalog.xml.orig to: C:\Customization\catalog.xml.
* Open the catalog.xml in Oxygen XML Editor and uncomment this line:

Code: Select all


  <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>   
* Rename C:\Customization\fo\xsl\custom.xsl.orig to: C:\Customization\fo\xsl\custom.xsl
* Modify the custom.xsl file by adding an import to bookmarks.xsl

Code: Select all


<xsl:import href="bookmarks.xsl"/>
* Create the bookmarks.xsl with the follow content:

Code: Select all


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:exsl="http://exslt.org/common"
xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
xmlns:exslf="http://exslt.org/functions"
xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
extension-element-prefixes="exsl"
exclude-result-prefixes="opentopic-index opentopic exslf opentopic-func ot-placeholder"
version="2.0">

<xsl:template name="createBookmarks">
<xsl:variable name="bookmarks" as="element()*">
<xsl:choose>
<xsl:when test="$retain-bookmap-order">
<xsl:apply-templates select="/" mode="bookmark"/>
</xsl:when>
<xsl:otherwise>

<!--
start patch
Generate the 'fo:bookmark' for the book title
-->
<fo:bookmark>
<xsl:attribute name="internal-destination">
<xsl:call-template name="generate-toc-id"/>
</xsl:attribute>

<xsl:variable name="bookmapTitle" select="//*[contains(@class, 'bookmap/mainbooktitle')]"/>
<fo:bookmark-title>
<xsl:value-of select="normalize-space($bookmapTitle)"/>
</fo:bookmark-title>

<!--
end patch
-->
<xsl:for-each select="/*/*[contains(@class, ' topic/topic ')]">
<xsl:variable name="topicType">
<xsl:call-template name="determineTopicType"/>
</xsl:variable>
<xsl:if test="$topicType = 'topicNotices'">
<xsl:apply-templates select="." mode="bookmark"/>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="($ditaVersion >= 1.1) and $map//*[contains(@class,' bookmap/toc ')][@href]"/>
<xsl:when test="($ditaVersion >= 1.1) and ($map//*[contains(@class,' bookmap/toc ')]
or /*[contains(@class,' map/map ')][not(contains(@class,' bookmap/bookmap '))])">
<fo:bookmark internal-destination="{$id.toc}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Table of Contents'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:when>
<xsl:when test="$ditaVersion >= 1.1"/>
<xsl:otherwise>
<fo:bookmark internal-destination="{$id.toc}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Table of Contents'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="/*/*[contains(@class, ' topic/topic ')] |
/*/ot-placeholder:glossarylist |
/*/ot-placeholder:tablelist |
/*/ot-placeholder:figurelist">
<xsl:variable name="topicType">
<xsl:call-template name="determineTopicType"/>
</xsl:variable>
<xsl:if test="not($topicType = 'topicNotices')">
<xsl:apply-templates select="." mode="bookmark"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="//opentopic-index:index.groups//opentopic-index:index.entry">
<xsl:choose>
<xsl:when test="($ditaVersion >= 1.1) and $map//*[contains(@class,' bookmap/indexlist ')][@href]"/>
<xsl:when test="($ditaVersion >= 1.1) and ($map//*[contains(@class,' bookmap/indexlist ')]
or /*[contains(@class,' map/map ')][not(contains(@class,' bookmap/bookmap '))])">
<fo:bookmark internal-destination="{$id.index}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Index'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:when>
<xsl:when test="$ditaVersion >= 1.1"/>
<xsl:otherwise>
<fo:bookmark internal-destination="{$id.index}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Index'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="exists($bookmarks)">
<fo:bookmark-tree>
<xsl:copy-of select="$bookmarks"/>
</fo:bookmark-tree>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
The template was copied from:
DITA-OT/plugins/org.dita.pdf2/xsl/fo/bookmarks.xsl.

The modifications are marked with start patch and end patch comments.

Re: Book title in bookmarks as first top level element

Posted: Sun Nov 22, 2015 11:55 pm
by josecotes
Thanks a lot! Worked like a charm.

Re: Book title in bookmarks as first top level element

Posted: Wed Mar 30, 2016 11:02 pm
by cjhukill
radu_pisoi wrote:Hi,

I assume that you want to change the bookmarks' structure for the DITA-OT PDF output.

DITA Open Toolkit PDF output can be customized in several ways:
* creating a DITA Open Toolkit plugin which adds extensions to the PDF plugin.
* creating a customization directory and using it from the PDF transformation scenario.

You can find more details in our user manual:
https://www.oxygenxml.com/doc/versions/ ... ation.html

For your request, you can follow the next procedure. This customization is based on the 'Custom directory' method. I've tested with DITA-OT 1.8.5.
* Copy the entire directory: DITA_OT_DIR\plugins\org.dita.pdf2\Customization to another location (for instance, C:\Customization).
* Rename C:\Customization\catalog.xml.orig to: C:\Customization\catalog.xml.
* Open the catalog.xml in Oxygen XML Editor and uncomment this line:

Code: Select all


  <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>   
* Rename C:\Customization\fo\xsl\custom.xsl.orig to: C:\Customization\fo\xsl\custom.xsl
* Modify the custom.xsl file by adding an import to bookmarks.xsl

Code: Select all


<xsl:import href="bookmarks.xsl"/>
* Create the bookmarks.xsl with the follow content:

Code: Select all


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:exsl="http://exslt.org/common"
xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
xmlns:exslf="http://exslt.org/functions"
xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
extension-element-prefixes="exsl"
exclude-result-prefixes="opentopic-index opentopic exslf opentopic-func ot-placeholder"
version="2.0">

<xsl:template name="createBookmarks">
<xsl:variable name="bookmarks" as="element()*">
<xsl:choose>
<xsl:when test="$retain-bookmap-order">
<xsl:apply-templates select="/" mode="bookmark"/>
</xsl:when>
<xsl:otherwise>

<!--
start patch
Generate the 'fo:bookmark' for the book title
-->
<fo:bookmark>
<xsl:attribute name="internal-destination">
<xsl:call-template name="generate-toc-id"/>
</xsl:attribute>

<xsl:variable name="bookmapTitle" select="//*[contains(@class, 'bookmap/mainbooktitle')]"/>
<fo:bookmark-title>
<xsl:value-of select="normalize-space($bookmapTitle)"/>
</fo:bookmark-title>

<!--
end patch
-->
<xsl:for-each select="/*/*[contains(@class, ' topic/topic ')]">
<xsl:variable name="topicType">
<xsl:call-template name="determineTopicType"/>
</xsl:variable>
<xsl:if test="$topicType = 'topicNotices'">
<xsl:apply-templates select="." mode="bookmark"/>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="($ditaVersion >= 1.1) and $map//*[contains(@class,' bookmap/toc ')][@href]"/>
<xsl:when test="($ditaVersion >= 1.1) and ($map//*[contains(@class,' bookmap/toc ')]
or /*[contains(@class,' map/map ')][not(contains(@class,' bookmap/bookmap '))])">
<fo:bookmark internal-destination="{$id.toc}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Table of Contents'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:when>
<xsl:when test="$ditaVersion >= 1.1"/>
<xsl:otherwise>
<fo:bookmark internal-destination="{$id.toc}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Table of Contents'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="/*/*[contains(@class, ' topic/topic ')] |
/*/ot-placeholder:glossarylist |
/*/ot-placeholder:tablelist |
/*/ot-placeholder:figurelist">
<xsl:variable name="topicType">
<xsl:call-template name="determineTopicType"/>
</xsl:variable>
<xsl:if test="not($topicType = 'topicNotices')">
<xsl:apply-templates select="." mode="bookmark"/>
</xsl:if>
</xsl:for-each>
<xsl:if test="//opentopic-index:index.groups//opentopic-index:index.entry">
<xsl:choose>
<xsl:when test="($ditaVersion >= 1.1) and $map//*[contains(@class,' bookmap/indexlist ')][@href]"/>
<xsl:when test="($ditaVersion >= 1.1) and ($map//*[contains(@class,' bookmap/indexlist ')]
or /*[contains(@class,' map/map ')][not(contains(@class,' bookmap/bookmap '))])">
<fo:bookmark internal-destination="{$id.index}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Index'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:when>
<xsl:when test="$ditaVersion >= 1.1"/>
<xsl:otherwise>
<fo:bookmark internal-destination="{$id.index}">
<fo:bookmark-title>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Index'"/>
</xsl:call-template>
</fo:bookmark-title>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</fo:bookmark>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="exists($bookmarks)">
<fo:bookmark-tree>
<xsl:copy-of select="$bookmarks"/>
</fo:bookmark-tree>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
The template was copied from:
DITA-OT/plugins/org.dita.pdf2/xsl/fo/bookmarks.xsl.

The modifications are marked with start patch and end patch comments.


I am using oXygen 14.2 and trying to resolve my issue of undefined 'fo:bookmark' and was reading this post. I tried the steps above, but was unable to get to the customization portion. Can you help me with that part?

Re: Book title in bookmarks as first top level element

Posted: Thu Mar 31, 2016 11:06 am
by radu_pisoi
Hi,
cjhukill wrote:
I am using oXygen 14.2 and trying to resolve my issue of undefined 'fo:bookmark' and was reading this post. I tried the steps above, but was unable to get to the customization portion. Can you help me with that part?
Unfortunately, oXygen 14.2 is in End Of Support state regarding to the End of Life (EOL) Policy Statement. The End of Support state means the technical support for that product version is no longer available.

However, I'm not sure if the PDF bookmarks customization described in this post is related with the problem that you described.

So, could you try to install the oXygen 17.1 with a trial license and check if your problem was fixed? If not, could you give us more details about your problem?

Re: Book title in bookmarks as first top level element

Posted: Thu Sep 08, 2016 9:34 pm
by rahulhr1985
How to make this book title from rendering right-to-left using writing-mode?

Re: Book title in bookmarks as first top level element

Posted: Fri Sep 09, 2016 8:56 am
by Radu
Hi,

I'm sorry but I do not understand, could you provide more details, maybe a screenshot? Are you publishing to PDF using Arabic? Are you using Apache FOP for rendering the PDF (the default engine bundled with Oxygen) or a commercial PDF engine like XEP or Antenna House?

Regards,
Radu

Re: Book title in bookmarks as first top level element

Posted: Fri Sep 09, 2016 10:32 am
by rahulhr1985
Hi,

Thank you for the quick reply. I have Arabic language PDF. In bookmark except booktitle all other topic title are rendering right to left. I am not able to see any writing-mode variable in bookmark-custom.xsl. Could you please help how can i render booktitle from right to left in bookmark?


Thanks
Rahul

Re: Book title in bookmarks as first top level element

Posted: Fri Sep 09, 2016 10:35 am
by rahulhr1985
Hi,

I am using Antenna house

Thanks
Rahul

Re: Book title in bookmarks as first top level element

Posted: Fri Sep 09, 2016 11:33 am
by Radu
Hi Rahul,

From what I tested with the default DITA OT PDF publishing the book title does not seem to appear at all in the Bookmarks view.
Are you publishing using the default PDF publishing or did you install the Antenna House special PDF publishing plugins?
https://www.antennahouse.com/antenna1/dita-pdf5-plugin/
Do you have a PDF XSLT customization which adds the book title to the bookmarks? If so, it might depend on what the customization does.

Regards,
Radu

Re: Book title in bookmarks as first top level element

Posted: Wed Mar 01, 2017 2:11 pm
by rgmetap
Hi Sir,

I need to pick <title> from ditamap and want to show it in header of body pages only in pdf . How can I do that?

Code: Select all

<map title="INSTRUCTIONS">
<title>WELCOME</title>
<topicref href="Concepts/c_message.dita"/>
I want to pick WELCOME

Re: Book title in bookmarks as first top level element

Posted: Thu Mar 02, 2017 10:15 am
by Radu
Hi,

You could probably try to create a PDF customization folder and override the template which customizes the header from the base XSLT stylesheet:

https://www.oxygenxml.com/doc/versions/ ... ined3.html

You can use an XPath to find the title of the current map.

Regards,
Radu

Re: Book title in bookmarks as first top level element

Posted: Tue Mar 07, 2017 9:45 am
by rgmetap
Hi Sir,

I need to pick the title value from front-matter by using xsl:marker and retrieve marker . I am unable to use it. Can you show some example for marker picking values ?

Re: Book title in bookmarks as first top level element

Posted: Tue Mar 07, 2017 10:06 am
by Radu
Hi,

Maybe you should register and ask around on the Yahoo Groups DITA Users List.

Regards,
Radu