hard-pagebreak doesn't work in oXygen 9.2

Here should go questions about transforming XML with XSLT and FOP.
mara66
Posts: 5
Joined: Mon Jun 09, 2008 1:55 pm

hard-pagebreak doesn't work in oXygen 9.2

Post by mara66 »

I use hard page breaks in DocBook via DocBook XSL: The Complete Guide (http://www.sagehill.net/docbookxsl/PageBreaking.html). But now after upgrade from oX. 9.1 to 9.2 it doesn't work. Can anybody help?
Thanks, Marek Rada
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by sorin_ristache »

Hello,

Version 9.2 comes with the namespace aware version of the DocBook XSL stylesheets but it is the same version number as in version 9.1 (DocBook XSL version 1.73.2). Do you run a DocBook customization layer? If yes you have to adjust your XSLT templates to match elements from the DocBook namespace ("http://docbook.org/ns/docbook") instead of elements from no namespace.


Regards,
Sorin
mara66
Posts: 5
Joined: Mon Jun 09, 2008 1:55 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by mara66 »

I made some tests and found out this:
I have two identical documents, one as DocBook 4.4 and other as DocBook 5 (headers originate from oXygen templates), and one common XSLT template. When I process DB5, then processing instructions work. When I process DB4, processing instructins don't work (I generate output with XEP). I'm almost (I don't want install older version) sure there wasn't this problem in oXygen 9.1.
I rate myself among beginners in DocBook so probably I do something wrong. I even don't quite understand your advice:
sorin wrote:you have to adjust your XSLT templates to match elements from the DocBook namespace ("http://docbook.org/ns/docbook") instead of elements from no namespace.
How? Processing instructions are not included in docbook namespace, are they?
Thanks for ideas,
MR
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by sorin_ristache »

Hello,

Can you post some short sample files of Docbook 4.4 and Docbook 5 or send us some sample files that show the problem?


Regards,
Sorin
mara66
Posts: 5
Joined: Mon Jun 09, 2008 1:55 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by mara66 »

Here is test document in DB 4.4

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.docbook.org/xml/4.4/docbookx.dtd">
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<article>
<title>Article Title</title>
<sect1>
<title>Preface</title>
<para>Testing document.</para>
</sect1>
<sect1>
<title>Chapter 1</title>
<para>There is some text in the first paragraph.</para>
<?hard-pagebreak?>
<sect2>
<title>Subchapter 1.1</title>
<para>I want this this subchapter to appear on the new page. This is why I posted processing instruction three lines above.</para>
</sect2>
</sect1>
</article>
Here is the same document in DB 5.0

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbook.rng" type="xml"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<info>
<title>Article Title</title>
<author>
<personname>
<firstname>My</firstname>
<surname>Name</surname>
</personname>
<address>
<city>My city</city>
<street>Street</street>
<postcode>Postcode</postcode>
<country>Country</country>
</address>
<email>e@mail.com</email>
</author>
</info>
<sect1>
<title>Preface</title>
<para>Testing document.</para>
</sect1>
<sect1>
<title>Chapter 1</title>
<para>here is some text in the first paragraph.</para>
<?hard-pagebreak?>
<sect2>
<title>Subchapter 1.1</title>
<para>I want this this subchapter to appear on the new page. This is why I posted processing instruction three lines above.</para>
</sect2>
</sect1>
</article>
And here is the template:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:saxon="http://icl.com/saxon" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
<xsl:import href="file:///c:/bin/oxygen/frameworks/docbook/xsl/fo/docbook.xsl"/>

<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after='page'/>
</xsl:template>

<xsl:template match="processing-instruction('linebreak')">
<fo:block/>
</xsl:template>

</xsl:stylesheet>
I have modified these files and unluckily I can't try now if they generate the strange behavior of processing that I have had descriped in previous post. I hope they do or I will look like an idiot :|
Marek

Update (12.6.2008 9:30): I tried these files just now and they realy generate the strange behaviour: DB 4.4 doesn't apply the processing instruction <? ... ?> and DB 5.0 does, when I use XEP. FOP doesn't apply processing instruction in both cases.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by sorin_ristache »

I tested with version 9.1 and the page break is inserted correctly. The difference is caused by the new version of the DocBook XSL stylesheets that are included in version 9.2. There is an xsl:apply-templates element on line 352 of frameworks/docbook/xsl/fo/sections.xsl which calls your template

Code: Select all

<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after='page'/>
</xsl:template>
when your stylesheet is applied to the DocBook 5 document but when it is applied to the DocBook 4 document it does not call your template. I could not figure out why it does not call your template but probably the difference is caused by the namespace of the DocBook 5 document (http://docbook.org/ns/docbook). The DocBook 4 document has no namespace. The DocBook XSL stylesheets that come with Oxygen 9.2 are namespace aware and this is a difference between the stylesheets that come with Oxygen 9.1. I will post a question on the DocBook list about this problem and I will keep you posted.


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by sorin_ristache »

Hello,

The processing instruction is ignored by the namespace aware version of the DocBook XSL stylesheets that come with Oxygen. When they process a DocBook 4 document (which is a no namespace document) the namespace aware stylesheets first preprocess the document for adding a namespace to each DocBook element but this preprocessing ignores comments and processing instructions. This is a bug which will be fixed in a later version of the DocBook XSL stylesheets. Until the DocBook team will fix this bug please download the no namespace version of the stylesheets (or use the stylesheets from Oxygen 9.1). Just unzip the distribution of the no namespace version of DocBook XSL and edit the reference to the DocBook stylesheet in your customization layer, something like:

Code: Select all

<xsl:import href="file:///c:/bin/docbook-1.74.0/xsl/fo/docbook.xsl"/>
Regards,
Sorin
mara66
Posts: 5
Joined: Mon Jun 09, 2008 1:55 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by mara66 »

Hello,

thank you for your work and explanation. That strange behaviour of DocBook was very confusing for me.

Thanks also for tip to fix. But I don't adhere to DocBook 4 so much, so in the case of need I will use oXygen convert schema and convert DB4 to DB5.

Regards,

Marek
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: hard-pagebreak doesn't work in oXygen 9.2

Post by sorin_ristache »

The processing instruction <?hard-pagebreak?> is processed correctly in a DocBook 5 document because the elements are already in the DocBook namespace so the page break is inserted correctly in the PDF result generated from a DocBook 5 document.


Regards,
Sorin
Post Reply