docbook-apps

  • 1.  Rotate Region Body for Landscape Pages

    Posted 07-03-2008 14:12
    Hello List,

    tried to set up a customized page sequence to rotate a region body. This Guide (http://www.sagehill.net/docbookxsl/PageDesign.html#LandscapePageSequence) was very helpful. So here my customizations:

    <xsl:template name="select.user.pagemaster">
    <xsl:param name="element"/>
    <xsl:param name="pageclass"/>
    <xsl:param name="default-pagemaster"/>

    <xsl:choose>
    <xsl:when test="@role = 'landscape'">landscape</xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$default-pagemaster"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="user.pagemasters">
    <fo:simple-page-master master-name="landscape-first"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="{$page.margin.top}"
    margin-bottom="{$page.margin.bottom}"
    margin-left="{$margin.left.inner}"
    margin-right="{$page.margin.outer}">
    <xsl:if test="$axf.extensions != 0">
    <xsl:call-template name="axf-page-master-properties">
    <xsl:with-param name="page.master">body-first</xsl:with-param>
    </xsl:call-template>
    </xsl:if>
    <fo:region-body margin-bottom="{$body.margin.bottom}"
    margin-top="{$body.margin.top}"
    reference-orientation="90"
    column-gap="{$column.gap.body}"
    column-count="{$column.count.body}">
    </fo:region-body>
    <fo:region-before region-name="xsl-region-before-first"
    extent="{$region.before.extent}"
    display-align="before"/>
    <fo:region-after region-name="xsl-region-after-first"
    extent="{$region.after.extent}"
    display-align="after"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="landscape-odd"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="{$page.margin.top}"
    margin-bottom="{$page.margin.bottom}"
    margin-left="{$margin.left.inner}"
    margin-right="{$page.margin.outer}">
    <xsl:if test="$axf.extensions != 0">
    <xsl:call-template name="axf-page-master-properties">
    <xsl:with-param name="page.master">body-odd</xsl:with-param>
    </xsl:call-template>
    </xsl:if>
    <fo:region-body margin-bottom="{$body.margin.bottom}"
    margin-top="{$body.margin.top}"
    reference-orientation="90"
    column-gap="{$column.gap.body}"
    column-count="{$column.count.body}">
    </fo:region-body>
    <fo:region-before region-name="xsl-region-before-odd"
    extent="{$region.before.extent}"
    display-align="before"/>
    <fo:region-after region-name="xsl-region-after-odd"
    extent="{$region.after.extent}"
    display-align="after"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="landscape-even"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="{$page.margin.top}"
    margin-bottom="{$page.margin.bottom}"
    margin-left="{$margin.left.outer}"
    margin-right="{$page.margin.inner}">
    <xsl:if test="$axf.extensions != 0">
    <xsl:call-template name="axf-page-master-properties">
    <xsl:with-param name="page.master">body-even</xsl:with-param>
    </xsl:call-template>
    </xsl:if>
    <fo:region-body margin-bottom="{$body.margin.bottom}"
    margin-top="{$body.margin.top}"
    reference-orientation="90"
    column-gap="{$column.gap.body}"
    column-count="{$column.count.body}">
    </fo:region-body>
    <fo:region-before region-name="xsl-region-before-even"
    extent="{$region.before.extent}"
    display-align="before"/>
    <fo:region-after region-name="xsl-region-after-even"
    extent="{$region.after.extent}"
    display-align="after"/>
    </fo:simple-page-master>

    <fo:page-sequence-master master-name="landscape">
    <fo:repeatable-page-master-alternatives>
    <fo:conditional-page-master-reference master-reference="blank"
    blank-or-not-blank="blank"/>
    <fo:conditional-page-master-reference master-reference="landscape-first"
    page-position="first"/>
    <fo:conditional-page-master-reference master-reference="body-odd"
    odd-or-even="odd"/>
    <fo:conditional-page-master-reference
    odd-or-even="even">
    <xsl:attribute name="master-reference">
    <xsl:choose>
    <xsl:when test="$double.sided != 0">landscape-even</xsl:when>
    <xsl:otherwise>landscape-odd</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </fo:conditional-page-master-reference>
    </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    </xsl:template>

    Then I set in my Input-Docbook-XML-File the attribute role to landscape in the appendix tag like this

    <appendix role="landscape">

    Next step was to generate output PDF with FOP 0.95 beta under Win and docbook-xsl-1.74.0. Result: Nothing. The appendix and integrated informaltable are still in portrait format.
    What is wrong?

    The very simplest way is to set orient=land to informaltable and this will rotate on page but with overfloating the page border ... :-(

    <informaltable orient="land">

    Next step is using the PSMI from here http://www.cranesoftwrights.com/resources/psmi/index.htm. This changed last in 2003. Couldn't this included in the Docbook-XSL-Stylesheet?

    Any suggestions?

    Thanks.
    Best Regards,
    Lee



    __________________________________________________________
    Gesendet von Yahoo! Mail.
    Dem pfiffigeren Posteingang.
    http://de.overview.mail.yahoo.com



  • 2.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-03-2008 15:39
    Hi,
    Your customization worked for me. I copied and pasted this into a short
    customization (with one correction: your page-sequence-master was using
    body-odd instead of landscape-odd), and processed it with xsltproc and fop
    0.95beta. When I put role="landscape" on chapter or appendix, they came out
    landscape in the PDF.

    You might take a peek inside your fo file to see if you are getting
    "landscape" on the page-sequence. That will tell you if something is going
    wrong with the stylesheet instead of fop.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 3.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-04-2008 07:44

    Hi,

    thanks. I changed it and processed again. The appendix is still in portrait
    not in landscape.

    First processed it with FOP 0.95 beta on Windows-System.
    Then processed it with xsltproc to generate a fo and have a look at this.
    Finding the page-master-sequence in the fo file

    <fo:page-sequence-master
    master-name="landscape"><fo:repeatable-page-master-alternatives><fo:conditional-page-master-reference
    master-reference="blank"
    blank-or-not-blank="blank"/><fo:conditional-page-master-reference
    master-reference="landscape-first"
    page-position="first"/><fo:conditional-page-master-reference
    master-reference="landscape-odd"
    odd-or-even="odd"/><fo:conditional-page-master-reference odd-or-even="even"
    master-reference="landscape-odd"/></fo:repeatable-page-master-alternatives></fo:page-sequence-master>

    But the PDF-Output is still in portrait also when I processed the FO file
    again with the latest build of FOP.

    Just add role="landscape" to my root article and processed again. Now the
    whole pdf output is in landscape ... header and footer still portrait -
    thats fine.

    The appendix I would like to output in landscape format is inside the root
    article and this is still in normal format portrait ... Could be this the
    reason? Should I create a separat appendix-file?

    Thank you very much.
    Best Regards,
    Lee


    Bob Stayton wrote:
    >
    > Hi,
    > Your customization worked for me. I copied and pasted this into a short
    > customization (with one correction: your page-sequence-master was using
    > body-odd instead of landscape-odd), and processed it with xsltproc and fop
    > 0.95beta. When I put role="landscape" on chapter or appendix, they came
    > out
    > landscape in the PDF.
    >
    > You might take a peek inside your fo file to see if you are getting
    > "landscape" on the page-sequence. That will tell you if something is
    > going
    > wrong with the stylesheet instead of fop.
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    >


  • 4.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-07-2008 16:53
    OK, your landscape page-masters are working, as indicated by the results
    when you put the attribute on the root element.

    The problem is that a page-master is applied at the page-sequence level, but
    an appendix inside an article does not generate its own page-sequence. The
    default assumption was that in an article, you don't want a page break when
    you start an appendix. To get your appendix to be landscaped, you'll need
    to change the behavior of the article template and the article/appendix
    template. Use something like this (untested) in a customization layer:

    At the end of the template with match="article" in fo/component.xsl, change

    <xsl:apply-templates/>
    </fo:flow>
    </fo:page-sequence>

    to:

    <xsl:apply-templates select="node()[not(self::appendix)]"/>
    </fo:flow>
    </fo:page-sequence>

    <xsl:apply-templates select="appendix"/>

    That excludes each appendix from the article's page-sequence and processes
    them after the article page-sequence ends.

    In the template with match="article/appendix", put all the content inside a
    variable, and then pass that as a parameter to the template named
    "page.sequence":

    <xsl:template match="article/appendix">
    <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
    </xsl:variable>

    <xsl:variable name="title">
    <xsl:apply-templates select="." mode="object.title.markup"/>
    </xsl:variable>

    <xsl:variable name="titleabbrev">
    <xsl:apply-templates select="." mode="titleabbrev.markup"/>
    </xsl:variable>

    <variable name="appendix.content">
    <fo:block id='{$id}'>
    <xsl:if test="$axf.extensions != 0">
    <xsl:attribute name="axf:outline-level">
    ...
    <xsl:apply-templates/>
    </fo:block>
    </variable>


    <xsl:call-template name="page-sequence">
    <xsl:with-param name="content" select="$appendix.content"/>
    </xsl:call-template>

    That will put the appendix into its own page-sequence.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 5.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-08-2008 12:42

    Hi,

    thank you very much.

    First of all, one correction ...
    <xsl:variable name="appendix.content">
    <fo:block id='{$id}'>
    <xsl:if test="$axf.extensions != 0">
    <xsl:attribute name="axf:outline-level">
    ...
    <xsl:apply-templates/>
    </fo:block>
    </xsl:variable>

    I was wondering why the variable appendix.content can't be find while
    processing. Just the prefix xsl: was missing.

    Second one is: A template named page-sequence does not exist or something
    else ElemTemplateElement-Error: page-sequence


    <xsl:call-template name="page-sequence">
    <xsl:with-param name="content" select="$appendix.content"/>
    </xsl:call-template>

    I tried to find the template called "page-sequence" but can't find it.

    Any further suggestions?

    Thanks,
    Best Regards,
    Lee



    Bob Stayton wrote:
    >
    > OK, your landscape page-masters are working, as indicated by the results
    > when you put the attribute on the root element.
    >
    > The problem is that a page-master is applied at the page-sequence level,
    > but
    > an appendix inside an article does not generate its own page-sequence.
    > The
    > default assumption was that in an article, you don't want a page break
    > when
    > you start an appendix. To get your appendix to be landscaped, you'll need
    > to change the behavior of the article template and the article/appendix
    > template. Use something like this (untested) in a customization layer:
    >
    > At the end of the template with match="article" in fo/component.xsl,
    > change
    >
    > <xsl:apply-templates/>
    > </fo:flow>
    > </fo:page-sequence>
    >
    > to:
    >
    > <xsl:apply-templates select="node()[not(self::appendix)]"/>
    > </fo:flow>
    > </fo:page-sequence>
    >
    > <xsl:apply-templates select="appendix"/>
    >
    > That excludes each appendix from the article's page-sequence and processes
    > them after the article page-sequence ends.
    >
    > In the template with match="article/appendix", put all the content inside
    > a
    > variable, and then pass that as a parameter to the template named
    > "page.sequence":
    >
    > <xsl:template match="article/appendix">
    > <xsl:variable name="id">
    > <xsl:call-template name="object.id"/>
    > </xsl:variable>
    >
    > <xsl:variable name="title">
    > <xsl:apply-templates select="." mode="object.title.markup"/>
    > </xsl:variable>
    >
    > <xsl:variable name="titleabbrev">
    > <xsl:apply-templates select="." mode="titleabbrev.markup"/>
    > </xsl:variable>
    >
    > <variable name="appendix.content">
    > <fo:block id='{$id}'>
    > <xsl:if test="$axf.extensions != 0">
    > <xsl:attribute name="axf:outline-level">
    > ...
    > <xsl:apply-templates/>
    > </fo:block>
    > </variable>
    >
    >
    > <xsl:call-template name="page-sequence">
    > <xsl:with-param name="content" select="$appendix.content"/>
    > </xsl:call-template>
    >
    > That will put the appendix into its own page-sequence.
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    >


  • 6.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-08-2008 17:33
    And that's why I should test before sending out suggestions. 8^)

    That should be name="page.sequence", not "page-sequence" (use dot, not
    dash).

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 7.  Re: [docbook-apps] Rotate Region Body for Landscape Pages

    Posted 07-09-2008 09:07

    Hi,

    thanks. This works fine :-)
    After making some customizations to my customizationlayer, now it looks
    better. For example, using . Have to put it at the end of the
    appendix.


    </appendix>

    Now all pages will counted correctly.

    Another thing is, I defined first pages without a footer content or just
    have another footer content than the other pages. The appendix has its own
    page-sequence and its own first page. So the first page footer content was
    empty because I defined an empty footer content for the first page. I
    changed my settings so every first page has the same footer content like the
    other pages have.
    But, is there a way to specify the first page footer content of such
    appendix like a normal page and still have another first page footer content
    for the real first page of the whole document?

    Best Regards,
    Lee


    Bob Stayton wrote:
    >
    > And that's why I should test before sending out suggestions. 8^)
    >
    > That should be name="page.sequence", not "page-sequence" (use dot, not
    > dash).
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    >