Try to customize different styles for odd- and even-numbered page headers, but failed

Post here questions and problems related to editing and publishing DITA content.
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

Hi:
Does anyone try to customize styles for odd- and even-numbered page headers and footers, and had a hard time trying to customize styles? I have to say, no matter how hard and how many times I tried, I could only get one style for both odd- and even-numbered page headers.

What I wanted to do was, for the odd-page header, I wanted to insert an image on the left end and the chapter title text (current-header, I used "fo:marker" to do this) on the right end. For the even-page header, I wanted to have the second-level (current-h2) topic title on the left end, and a company image on the right. Here are the steps I followed:

1. In my customized DITA-OT, under cfg/fo/xsl, in my custom.xsl, I imported static-content.xsl.

2. I then copy the templates for "insertBodyOddHeader", "insertBodyEvenHeader","insertFirstOddHeader", "insertBodyLastHeader" from "static-content.xsl", and likewise similar templates for footers, and began my customization.

3. But, after successfully customized the odd-page header that has an image positioned on the left end, and the chapter title on the right, the even-page header looks exactly the same as the odd-page header, even if under the "insertBodyEvenHeader" template, I reversed the order, and had <fo:marker> retrive "current-h2", the even-page header still came out the same as the odd-page header.

4. I then used the default DITA-OT that came with Oxygen without any customizations to generate a PDF file, odd- and even-page headers and footers still looked exactly the same.

I began to wonder if that had something to do with FOP itself, so I used XMetaL to generate a PDF file (XMetaL came with the RenderX renderer), the generated PDF has different styles for odd- and even-page headers.

Does any of you know whether this is problem related to the renderer? If you think this is the problem with my customizations, I would be happy to send you my stylesheets offline if you are interested in taking a look, thanks.
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

In case I forgot to mention, I used Apache FOP to generate PDFs.
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by radu_pisoi »

Hi,

Did you try to set the value for mirror-page-margins XSLT variable to true?

Code: Select all


<xsl:variable name="mirror-page-margins" select="true()"/>
By default, this variable is set to false that allows you to customize only the odd pages.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

Hi Radu:
After I changed the value to

Code: Select all

true
in <xsl:variable name="mirror-page-margins" select="false()"/>, fop output an error: ""fo:marker" is not a valid child of "fo:block"! An fo:marker is permitted only as the descendant of an fo:flow." , but if I changed the value back to

Code: Select all

false
, a PDF was generated successfully.

In case I also forgot to mention, I used <fo:retrieve marker> to output header texts (current-header, current-h2, etc.). Thanks.
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by radu_pisoi »

Hi,

It would be easier for us to debug your code if we take a look over it.

Could you send us your customization at support@oxygenxml.com?
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

Hi Radu:
I just sent the Google Drive link of my customization to you, if you have trouble downloading it, please let me know, thanks again.
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

Hi Radu:

I removed <xsl:apply-templates /> from template "insertBodyEvenHeader:, and yes, FOP did transform my PDF output successfully. Yet that still does not solve my original problem of not having different styles for odd- and even-page headers; I still have logo on the far left and chapter titles on the far right on every header, my problem was originally explained in the top thread.

Although you recommended me to set the value to "true" for

Code: Select all

<xsl:variable name="mirror-page-margins" select="true()"/>
, and that did work with the default DITA-OT that came with Oxygen 18 (and 17.1), it didn't however, work with my current customization; what I want is to have a logo on the far right and a chapter title (topic.title) on the far left for the odd-page header, and for the even-page header, I want a logo on the far right and a "running header" (topic.topic.title) on the far left.

After digging into my stylesheets for many days, I've still yet to find the problem, can you help me again? Thank you.
surangamas
Posts: 47
Joined: Tue Feb 21, 2012 10:17 pm

Re: Try to customize different styles for odd- and even-numbered page headers, but failed

Post by surangamas »

Hi Radu:

Never mind, I found out that the problem was with the value in this variable:

Code: Select all

 <xsl:variable name="mirror-page-margins" select="false()"/>
.
I forgot that the value wasn't changed to "true", hence the problem, thanks for your help, removing <xsl:"apply-templates /> did solve my problem, Oxygen rocks!
Post Reply