Page 1 of 1

pagebreak before element identified with attribute

Posted: Tue Oct 09, 2018 3:43 pm
by dangler
Hi,

I am trying to identify an element by attribute and then add a pagebreak before. Right now I can identify the element and the pagebreak works but the element is removed. I managed to copy the content with <xsl:copy-of but the formatting is not applied. Is there some option to add the formatting by calling the title formatting? I already tried to create a new <title> element inside the template node but nothing is created when doing this.

The following example results in a pagebreak but without the formatting of the title:

Code: Select all

<xsl:template match="//title[@formatting='pageBreakBefore']">
<fo:block page-break-before="always"/>
<xsl:copy-of select="node()"/>
</xsl:template>

Code: Select all

  <title formatting="pageBreakBefore">Some Title</title>
Thanks a lot in advance!

Re: pagebreak before element identified with attribute

Posted: Tue Oct 09, 2018 4:05 pm
by Radu
Hi,

The XSLT is applied on a DITA document and it produces XSL-FO output.
Using "xsl:copy-of" means that the DITA <title> element will be copied to the output XSL-FO as a <title> element instead of being processed as an XSL-FO element.
My recommendation:

Code: Select all

<xsl:template match="title[@formatting='pageBreakBefore']">
<fo:block page-break-before="always"/>
<xsl:next-match/>
</xsl:template>
That <xsl:next-match/> means to continue the processing by applying the default XSLT template which matches the title element.
Using <xsl:apply-imports/> instead of xsl:next-match might also work.

An alternative is to specify the page break using a processing instruction:

https://github.com/dita-community/org.d ... page-break

Regards,
Radu

Re: pagebreak before element identified with attribute

Posted: Fri Nov 23, 2018 5:21 pm
by Quick van Rijt
You tagging a title with an attribute to trigger a page-break.
If your goal is to start selected topics of interest on a new page, check-out the following plugin:

https://github.com/dita-community/org.d ... page-break

I just submitted a solution to use:

Code: Select all


<prolog>
<?pagebreak?>
</prolog>