DITA-OT PDF plugin

Here should go questions about transforming XML with XSLT and FOP.
SimonH
Posts: 19

DITA-OT PDF plugin

Tue Apr 12, 2016 3:35 pm

How do I change the behavior of chapter numbering. The default behavior is to generate chapters numbered 1 to N in each part. I want chapters to be numbered continuously.

Regards,
Simon
SimonH
Posts: 19

Re: DITA-OT PDF plugin

Tue Apr 12, 2016 3:40 pm

I'm using Oxygen 17...
Radu
Posts: 5563

Re: DITA-OT PDF plugin

Tue Apr 12, 2016 4:03 pm

Hi Simon,

Could you double check the default behavior? From what I tested the chapters are numbered from start to finish of the document without their number being reset in each part.
Would it be possible that you have a PDF customization which changed the default behavior?

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

Re: DITA-OT PDF plugin

Wed Apr 13, 2016 10:54 am

It's just the default bundled installation running DITA-OT 1.8.5.

-Simon
Radu
Posts: 5563

Re: DITA-OT PDF plugin

Wed Apr 13, 2016 11:55 am

Hi Simon,

In my initial test I only tested with the DITA OT 2.x which is bundled with Oxygen 17.1 and it behaved the way you want.
Indeed the DITA OT 1.8 does reset chapters for each part but this was fixed in DITA OT 2.x:

https://github.com/dita-ot/dita-ot/issues/1272

In the XSLT stylesheet:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\commons.xsl

there is a template which computes the chapter number:

Code: Select all

 <xsl:template match="*[contains(@class, ' bookmap/chapter ')] |
                         opentopic:map/*[contains(@class, ' map/topicref ')]" mode="topicTitleNumber" priority="-1">


The DITA OT 2.x equivalent which fixes the problem looks like this:

Code: Select all

    <xsl:template match="*[contains(@class, ' bookmap/chapter ')] |
                         opentopic:map/*[contains(@class, ' map/topicref ')]" mode="topicTitleNumber" priority="-1">
      <xsl:variable name="chapters">
        <xsl:document>
          <xsl:for-each select="$map/descendant::*[contains(@class, ' bookmap/chapter ')]">
            <xsl:sequence select="."/>
          </xsl:for-each>
        </xsl:document>>
      </xsl:variable>
      <xsl:for-each select="$chapters/*[current()/@id = @id]">
        <xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
      </xsl:for-each>
    </xsl:template>


Instead of directly making changes to the DITA OT XSLTs the proper way to customize the XSLT stylesheets for the PDF output would be this one:

https://www.oxygenxml.com/doc/versions/17.1/ug-editor/#topics/dita_pdf_output_customization.html

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

Re: DITA-OT PDF plugin

Wed Apr 13, 2016 8:07 pm

Thanks Radu. That worked.
SimonH
Posts: 19

Re: DITA-OT PDF plugin

Thu Apr 14, 2016 1:20 pm

I have another question. I don't know if I need to modify the XSLT or if I'm missing an attribute on my XML.

I have an xref to another topic in a step:

<step>
<cmd><xref href="DeactivatingLicense.dita">Deactivate the license on your existing
computer.</xref></cmd>
</step>

The PDF output generated it:

"1. Deactivate the license on your existing computer."

How do I make the xref state the page number of the topic as below when outputting to PDF.

"1. Deactivate the license on your existing computer, see page XX."

Regards,
Simon
SimonH
Posts: 19

Re: DITA-OT PDF plugin

Thu Apr 14, 2016 1:23 pm

I may have answered this myself. It's because I have a title specified whereas if i just let DITA autogenerate the text from the topic tile it includes the page number.
Radu
Posts: 5563

Re: DITA-OT PDF plugin

Thu Apr 14, 2016 1:44 pm

Hi Simon,

Right, once you enter content inside the xref, the automatic link text generation will not be done.

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

Re: DITA-OT PDF plugin

Tue Apr 19, 2016 11:22 am

I'm trying to rearrange the table of contents so I have a page number before the topic title. I have this working by moving the page number block above the title. I then use the fo:leader to indent the titles depending on their level. However, where the page number changes from single digits to double or triple there is a slight difference in the alignment of the titles.

I was hoping I could wrap the page number in an inline-container with a fixed width like this:

Code: Select all

                                <fo:inline-container width="2cm" >
                                   <fo:inline xsl:use-attribute-sets="__toc__page-number">
                                    <fo:page-number-citation>
                                        <xsl:attribute name="ref-id">
                                            <xsl:call-template name="generate-toc-id"/>
                                        </xsl:attribute>
                                    </fo:page-number-citation>
                                   </fo:inline>                           
                                </fo:inline-container>

However, when I try transform I get and error that fo:inline is not a valid child of fo:inline-container. I'm not sure what is treated as a valid child of inline-container as nothing seems to work.

Any ideas how else I could achieve fixing the width of the page number field so the titles align regardless of the number of digits in the page number.

-Simon
Radu
Posts: 5563

Re: DITA-OT PDF plugin

Tue Apr 19, 2016 2:32 pm

Hi Simon,

The idea to have the page number to the left of the topic titles seems quite strange to me... Is it for Arabic content?
About fo:inline-container, the specification states it allows block-type elements:

https://www.w3.org/TR/xsl/#fo_inline-container

Not sure what to suggest in this case, maybe you could ask around on the DITA Users List Yahoo Group, see if the people registered on it have better approaches.

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

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest