title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Here should go questions about transforming XML with XSLT and FOP.
fmasson85
Posts: 4
Location: Québec City, Canada

title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Fri Feb 01, 2013 7:24 pm

I had a customization, mainly in the commons.xsl code in Oxygen 13 that would add leading numbers in headings for PDF output.

For example:

1.1 Chapter One, First Heading

1.2 Chapter One, Second Heading

1.2.1 Chapter One, First Subheading of Second Heading

1.2.2 Chapter One, Second Subheading of Second Heading

.....

2.1 Chapter Two, First Heading

2.2 Chapter Two, Second Heading

... and so forth.

It worked well with Oxygen 14.1, but now customizing the commons.xsl using the same code:

<!-- François Masson 08-23-2012 Outline numbering -->

<!-- Maximum level to which Topic titles are numbered. See "getTitleNumber" template below -->

<xsl:variable name="topicTitle.numLevel">6</xsl:variable>

<!-- getNonumTitle template is a copy of the original getTitle
template that will be used for titles that should not be numbered. -->

<xsl:template name="getNonumTitle"><!-- get fully-processed title content by
whatever mechanism -->
<xsl:choose>
<!-- add keycol here once implemented-->
<xsl:when test="@spectitle">
<xsl:value-of select="@spectitle"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- getTitle template override. See demo\fo\xsl\fo\commons.xsl -->
<xsl:template name="getTitle">
<!-- get fully-processed title content by whatever mechanism -->
<xsl:variable name="titleNumber">
<!--Add title numbers to topic titles ONLY-->
<xsl:if test="parent::*[contains(@class,'topic/topic')]">
<xsl:call-template name="getTitleNumber" />
</xsl:if>
</xsl:variable>
<xsl:choose>
<!-- add keycol here once implemented-->
<xsl:when test="@spectitle">
<xsl:value-of select="@spectitle" />
</xsl:when>
<!-- Suppress numbering of the glossary -->
<xsl:when test="parent::*[contains(@class,'topic/topic')][@id =
//*/glossarylist/@id]">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$titleNumber" />
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Number topics down to level = $topicTitle.numLevel -->
<xsl:template name="getTitleNumber">
<!-- Find the -->
<xsl:variable name="level"
select="ancestor::*[contains(@class,' topic/topic ')]" />
<xsl:variable name="appendix"
select="//*[contains(@class,' bookmap/appendix ')]" />
<xsl:choose>
<xsl:when test="count($level)=1 and parent::*/@id[. = //*/chapter/@id]">
<xsl:for-each select="$level">
<xsl:value-of
select="count(preceding-sibling::*[contains(@class,' topic/topic ')]) + 1"
/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:when>
<xsl:when test="count($level)=1 and parent::*/@id[. = //*/appendix/@id]">
<!-- from="*[contains(@class,' topic/topic ')][@id[. = $appendix[1]/@id]"-->
<!-- <xsl:number level="multiple" format="A"/>-->
<xsl:for-each select="$level">
<xsl:number
value="count(preceding-sibling::*[contains(@class,' topic/topic ')][@id =
//*/appendix/@id]) + 1"
format="A"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:when>
<xsl:when
test="not(count($level) &gt; $topicTitle.numLevel) and ancestor::*/@id[. =
//*/appendix/@id]">
<xsl:number
count="*[contains(@class,' topic/topic ')][@id =
//*/appendix/@id|//*/topicref/@id]"
level="multiple" format="A.1" />
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="not(count($level) &gt; $topicTitle.numLevel)">
<xsl:number count="*[contains(@class,' topic/topic ')]"
level="multiple" format="1.1" />
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise />
<!-- no title numbering at nth level where n > $topicTitle.numLevel -->
</xsl:choose>
</xsl:template>


<xsl:template match="*" mode="getTitle">
<xsl:choose>
<!-- add keycol here once implemented-->
<xsl:when test="@spectitle">
<xsl:value-of select="@spectitle"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

does not add leading numbers in headings for PDF output.

I don't get errors, and the PDF gets built, but not showing leading numbers.

Any idea how I can get leading numbers in the pdf with the new org.dita.pdf2?

Thanks
fmasson85
Posts: 4
Location: Québec City, Canada

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Fri Feb 01, 2013 7:26 pm

In my previous post I stated that my customization worked in Oxygen 14.1, it was aorking in Oxygen 13, it is not working in Oxygen 14.1.

:(
fmasson85
Posts: 4
Location: Québec City, Canada

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Fri Feb 01, 2013 7:58 pm

Well,

I was able to replicate the customization that worked in Oxygen 13 in Oxygen 14.1 by adding these files to my customization:

<?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:opentopic="http://www.idiominc.com/opentopic"
exclude-result-prefixes="opentopic"
version="1.1">

<xsl:import href="root-processing.xsl"/>
<xsl:import href="basic-settings.xsl"/>
<xsl:import href="links.xsl"/>
<xsl:import href="task-elements.xsl"/>

<xsl:import href="commons.xsl"/>
<xsl:import href="commons_1.0.xsl"/>
<xsl:import href="preface.xsl"/>
<xsl:import href="front-matter.xsl"/>
<xsl:import href="layout-masters.xsl"/>
<xsl:import href="static-content.xsl"/>
<xsl:import href="ui-domain.xsl"/>
<xsl:import href="sw-domain.xsl"/>

</xsl:stylesheet>
Radu
Posts: 5563

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Mon Feb 04, 2013 10:56 am

Hi,

Thanks for sharing the solution with everybody else.
Oxygen 14.1 comes with DITA Open Toolkit 1.6.1 (this information can be found in the Help->About->Frameworks tab) while Oxygen 13 came with an older DITA Open Toolkit.
Indeed new DITA OT releases usually change things in the XSLs which also need to be updated in the customizations. Usually the DITA OT has a release changes page which may also be handy, here's the one from 1.6.1:

http://dita-ot.sourceforge.net/1.6.1/readme/changes/rel1.6.html

Of course, as an alternative, you can use an external DITA OT installation (you could copy the one from Oxygen as a starting point) and thus keep updating Oxygen but preserve the same DITA OT for publishing:

http://www.oxygenxml.com/doc/ug-oxygen/index.html#tasks/use-new-dita-ot.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
lanton
Posts: 1

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Thu Aug 22, 2013 6:19 pm

Hi,

I am using Oxygen XML Editor 14.2 and DITA Open Toolkit 1.6.1. I am trying to get the title numbering in PDF2 but I am having problems. I have tried to do the customization explained in this post but I didn't get results.

Could anyone help me with this, please?

Thanks in advance.

Best regards,
Radu
Posts: 5563

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Fri Aug 23, 2013 2:11 pm

Hi,

The code sample was posted by one of our users and was not tested by us in any way.
I see that you also received some feedback about this on the DITA Users List, hopefully it will help you make the customization.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
cbgarcia
Posts: 10

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Wed Sep 11, 2013 6:30 pm

lanton wrote:Hi,

I am using Oxygen XML Editor 14.2 and DITA Open Toolkit 1.6.1. I am trying to get the title numbering in PDF2 but I am having problems. I have tried to do the customization explained in this post but I didn't get results.

Could anyone help me with this, please?

Thanks in advance.

Best regards,


Can anybody answer this question?
cbgarcia
Posts: 10

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Fri Sep 13, 2013 7:41 pm

For Oxygen 14.2, I made some modifications to the above code:

Code: Select all

    <!-- François Masson 08-23-2012 Outline numbering -->
   
    <!-- Maximum level to which Topic titles are numbered. See "getTitleNumber" template below -->
   
    <xsl:variable name="topicTitle.numLevel">6</xsl:variable>
   
    <!-- getNonumTitle template is a copy of the original getTitle
template that will be used for titles that should not be numbered. -->
   
    <xsl:template name="getNonumTitle"><!-- get fully-processed title content by
whatever mechanism -->
        <xsl:choose>
            <!-- add keycol here once implemented-->
            <xsl:when test="@spectitle">
                <xsl:value-of select="@spectitle"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
     
    <!-- Number topics down to level = $topicTitle.numLevel -->
    <xsl:template name="getTitleNumber">
        <!-- Find the -->
        <xsl:variable name="level"
            select="ancestor::*[contains(@class,' topic/topic ')]" />
        <xsl:variable name="appendix"
            select="//*[contains(@class,' bookmap/appendix ')]" />
        <xsl:choose>
            <xsl:when test="count($level)=1 and parent::*/@id[. = //*/chapter/@id]">
                <xsl:for-each select="$level">
                    <xsl:value-of
                        select="count(preceding-sibling::*[contains(@class,' topic/topic ')]) + 1"
                    />
                    <xsl:text> </xsl:text>
                </xsl:for-each>
            </xsl:when>
            <xsl:when test="count($level)=1 and parent::*/@id[. = //*/appendix/@id]">
                <!-- from="*[contains(@class,' topic/topic ')][@id[. = $appendix[1]/@id]"-->
                <!-- <xsl:number level="multiple" format="A"/>-->
                <xsl:for-each select="$level">
                    <xsl:number
                        value="count(preceding-sibling::*[contains(@class,' topic/topic ')][@id =
                        //*/appendix/@id]) + 1"
                        format="A"/>
                    <xsl:text> </xsl:text>
                </xsl:for-each>
            </xsl:when>
            <xsl:when
                test="not(count($level) &gt; $topicTitle.numLevel) and ancestor::*/@id[. =
                //*/appendix/@id]">
                <xsl:number
                    count="*[contains(@class,' topic/topic ')][@id =
                    //*/appendix/@id|//*/topicref/@id]"
                    level="multiple" format="A.1" />
                <xsl:text> </xsl:text>
            </xsl:when>
            <xsl:when test="not(count($level) &gt; $topicTitle.numLevel)">
                <xsl:number count="*[contains(@class,' topic/topic ')]"
                    level="multiple" format="1.1" />
                <xsl:text> </xsl:text>
            </xsl:when>
            <xsl:otherwise />
            <!-- no title numbering at nth level where n > $topicTitle.numLevel -->
        </xsl:choose>
    </xsl:template>
   
   
    <xsl:template match="*" mode="getTitle">
        <xsl:variable name="titleNumber">
            <!--Add title numbers to topic titles ONLY-->
            <xsl:if test="parent::*[contains(@class,'topic/topic')]">
                <xsl:call-template name="getTitleNumber" />
            </xsl:if>
        </xsl:variable>
        <xsl:choose>
            <!-- add keycol here once implemented-->
            <xsl:when test="@spectitle">
                <xsl:value-of select="@spectitle" />
            </xsl:when>
            <!-- Suppress numbering of the glossary -->
            <xsl:when test="parent::*[contains(@class,'topic/topic')][@id =
                //*/glossarylist/@id]">
                <xsl:apply-templates />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$titleNumber" />
                <xsl:apply-templates />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
Radu
Posts: 5563

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Mon Sep 16, 2013 8:41 am

Hi,

Thanks for sharing the customization.
Just to see that I understand, the title of a topic appears both in the table of contents and in the main content. This customization is for the main content right?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
cbgarcia
Posts: 10

Re: title numbering in PDF2 moving from Oxygen Author 13 to

Thu Sep 19, 2013 10:05 pm

Hi Radu,

Customization is for both topic title and table of contents.
BogdanM777
Posts: 68
Location: Canada

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Tue Nov 03, 2015 8:10 pm

Hi,

I found this post when I was looking for modalities to have my topics numbered, and I applied it.
It is working for me, however I did not get it to work for my Glossary entries.
I have my glossary declared in a glossary.ditamap, and I have it referenced in the main ditamap of the project:

<chapter href="glossary/glossaryOverview.dita">
<topicref format="ditamap" href="glossary.ditamap"/>
</chapter>

Is there a way to have your customization work in my situation?
I am sorry, however I am a beginner DITA user, so I do not quite know all the intricacies of the tool, and also I do not have the time luxury of studying too deep the documentations, therefore I rely on this kind of "ready to use" solutions.
I am using oXygen XML Editor 17.1
If you could help me, I would highly appreciate it.
radu_pisoi
Posts: 327
Location: Craiova

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Wed Nov 04, 2015 2:44 pm

Hi,

I have tried this customization with a small DITA Map sample in oXygen 17.1. In my case the topic's title is preceded by a number also for Glossary entries, so this customization seems to work.

In order to analyze your problem, could you send us a small DITA Map sample and also the PDF customization folder to support@oxygenxml.com?
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Wed Nov 04, 2015 5:10 pm

Hi Radu,

By "a small ditamap" you mean a fragment of my ditamap? Or a sample of the structure I used for the ditamap?
Also, when you say "PDF customization folder", which folder do you mean? I did the changes inside the DITA OT folder having all changes commented in case I need to remove them, or someone else has to process them.

Thank you.
radu_pisoi
Posts: 327
Location: Craiova

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Thu Nov 05, 2015 11:53 am

Hi,
By "a small ditamap" you mean a fragment of my ditamap? Or a sample of the structure I used for the ditamap?

We need a DITA map file plus with the referenced topics. Also, it's good to keep the structure of the original DITA map. Thus, if you have DITA sub-maps in the original structure please keep them in the sample DITA map.

Also, when you say "PDF customization folder", which folder do you mean? I did the changes inside the DITA OT folder having all changes commented in case I need to remove them, or someone else has to process them.

Oops, I think you have chosen the wrong way to customize the DITA-OT output:
  • it will be hard to update your DITA-OT to a newer version.
  • it will be hard to manage the differences between DITA-OT implementation and your customization

Now, a better solution is to choose one of the mechanisms offered by the DITA Open toolkit for PDF customization:
  • create a DITA Open Toolkit plugin which adds extensions to the PDF plugin. See the 'Customizing PDF output' section from DITA Open Toolkit 1.8 Documentation
  • create a customization directory
You can find more details in http://oxygenxml.com/doc/versions/17.1/ ... ation.html.

So, depending on the solution you have chosen, please send us your PDF customization plugin/folder and the DITA map sample.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
rdelong
Posts: 61

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Tue Nov 22, 2016 10:28 pm

Thanks for this exchange of information. I couldn't follow the DITA user's group thread on this topic with its 46 replies.

The question that I have is, How do I start numbering at Chapter 1. Currently, the numbering starts at the first topic within the bookmap and Preface, so in my case, Chapter 1 is section number 3.
radu_pisoi
Posts: 327
Location: Craiova

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Thu Nov 24, 2016 12:23 pm

Hi,

A DITA-OT PDF2 customization plugin that can be configured to generates numbers before topic's title
is available on GITHUB: https://github.com/radu-pisoi/org.dita. ... .numbering. It was tested with DITA-OT 2.4.

To install this plugin please follow the next steps:
  • Download DITA-OT 2.4
  • Copy this customization plugin into the DITA-OT/plugins folder
  • Run DITA-OT Integrator
  • Set the numbers-before-title parameter to yes to enable this feature.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
rdelong
Posts: 61

Re: title numbering in PDF2 moving from Oxygen Author 13 to Oxygen Author 14.1

Mon Nov 28, 2016 8:05 pm

Thanks for this plugin! This is exactly what I was looking for. I tested on OT 1.8.4 and it works fine. It's also faster. Using the code above, it took 22 minutes to create a 800-page Admin Guide. With the plugin, it took only 7 minutes!

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest