Line break inside <mainbooktitle> element

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
BogdanM777
Posts: 68
Location: Canada

Line break inside <mainbooktitle> element

Mon Nov 02, 2015 6:51 pm

Hi Guys,

I would have a question regarding the <mainbooktitle> element.
Is it possible to have a line break inside this element? That means, if I would like to have the title on two lines, e.g.

<mainbooktitle>Line 1 Line 2</mainbooktitle>

what should I insert between the Line 1 & Line 2?
Till now I managed to do that using a blank image, however I imagine that this is not quite professional, right?
So, I was wondering if DITA has any solution to this type of situation.

Thank you very much,

Bogdan
BogdanM777
Posts: 68
Location: Canada

Re: Line break inside <mainbooktitle> element

Mon Nov 02, 2015 6:57 pm

I tried to use the solution offered by you in this article:

https://www.oxygenxml.com/dita/stylegui ... itles.html

However the space between the lines is way too big, so I was wondering if there would be another solution.
Also, right now, in the title, using the 1 pixel/1 pixel image solution, the two lines are not aligned perfectly to the right hand side, so I was wondering what would be a solution to that as well.

Thank you very much
bogdan_cercelaru
Posts: 203

Re: Line break inside <mainbooktitle> element

Wed Nov 04, 2015 10:56 am

Hello,

Unfortunately, DITA does not offer any solution to this type of situation. However, the following procedure offer you a workaround to obtain a line break using a customization directory for PDF transformation.
  1. Copy the entire directory: DITA_OT_DIR\plugins\org.dita.pdf2\Customization to another location (for instance, C:\Customization).
  2. Rename C:\Customization\catalog.xml.orig to: C:\Customization\catalog.xml.
  3. Open the catalog.xml in Oxygen XML Editor and uncomment this line:

    Code: Select all

    <!--uri name="cfg:fo/attrs/custom.xsl" uri="fo/xsl/custom.xsl"/-->
    So now it looks like this:

    Code: Select all

    <uri name="cfg:fo/attrs/custom.xsl" uri="fo/xsl/custom.xsl"/>
  4. Rename the file: C:\Customization\fo\xsl\custom.xsl.orig to: C:\Customization\fo\xsl\custom.xsl
  5. Open the custom.xsl file in Oxygen XML Editor and add the following template:

    Code: Select all

    <xsl:template match="processing-instruction('linebreak')">
           <fo:block/>
    </xsl:template>
    . Now, custom.xsl has the following 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"
        version="2.0">
        <xsl:template match="processing-instruction('linebreak')">
                <fo:block/>
        </xsl:template>
    </xsl:stylesheet>
  6. Edit the DITA Map to PDF transformation scenario and in the Parameters tab, set the customization.dir parameter to C:\Customization.
  7. Now you can use the following PI to insert a new line

    Code: Select all

    <?linebreak?>

You can find more information regarding PDF customization in our user-guide: Customizing DITA Transformations / DITA to PDF Output Customization / Creating a Customization Directory for PDF Output

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: Line break inside <mainbooktitle> element

Wed Nov 04, 2015 4:54 pm

Hi Bogdan,

I followed your instructions and I inserted in the <mainbooktitle> something like:

<mainbooktitle>Title part 1<?linebreak?>part 2</mainbooktitle>

When I ran the custom PDF transformation, I got the error message:

Description: I/O error reported by XML parser processing file:/D:/Customization/fo/attrs/custom.xsl: D:\Customization\fo\attrs\custom.xsl (The system cannot find the file specified) Cause: java.io.FileNotFoundException: D:\Customization\fo\attrs\custom.xsl (The system cannot find the file specified)

So I went into the specified directory and changed the name of the file from custom.xml.orig to custom.xml, and I ran the transformation again, however the pdf I obtained did not have any line break between the Title part 1 and part 2.
Did I do something wrong?

Thank you
bogdan_cercelaru
Posts: 203

Re: Line break inside <mainbooktitle> element

Wed Nov 04, 2015 5:46 pm

Hi,

Sorry, my mistake. Step 3 in my previous message should have been:
  • 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"/-->
    So now it looks like this:

    Code: Select all

    <uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/>

Regards,
Bogdan
Bogdan Cercelaru
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
BogdanM777
Posts: 68
Location: Canada

Re: Line break inside <mainbooktitle> element

Wed Nov 04, 2015 6:02 pm

Thank you Bogdan!
Now it works "licking the button"!

Have a great day!
rgmetap
Posts: 12
Location: Pune , India

Re: Line break inside <mainbooktitle> element

Wed May 10, 2017 8:45 am

I have something similar to that , but I am using ditamap.

I want to give line break in<map><title>something<sub>hello</sub></title></map>on <sub> element in frontmatter. How can I achieve this? Now it is showing in same line.
Rohit Ghosh
Jr. Software Developer
ionela
Posts: 196

Re: Line break inside <mainbooktitle> element

Thu May 11, 2017 12:27 pm

Hi,

An alternative to achieve this is to convert your DITA map to a bookmap.Then, for a bookmap you can insert a booktitle element. The booktitle element contains the title information such as <mainbooktitle> and <booktitlealt>. This way you can have the two titles each for them shown on a different line in the PDF output.
https://www.oxygenxml.com/dita/1.3/specs/langRef/technicalContent/bookmap.html
https://www.oxygenxml.com/dita/1.3/specs/langRef/technicalContent/booktitlealt.html

You can check this structure also in our sample project DITA>it-book>taskbook.ditamap.

I hope this helps.

Regards,
Ionela
Ionela Istodor
oXygen XML Editor and Author Support

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 0 guests