[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] fo:multi-switch or alternative


Subject: Re: [xsl] fo:multi-switch or alternative
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 29 Sep 2012 09:06:30 -0400

At 2012-09-29 08:15 +0200, Jesper Tverskov wrote:
Kevin Brown wrote:
> Question: Can the table + content be in its own page-sequence?
> If the answer is yes, I do not see why you could not use ...
...
> Or, if preferred without "only" which I forget may also be a 1.1 concept:
...

Sounds interesting but I would need more help. If you have the time,
please modify Ken's solution so it not only works with XSL-FO 1.1 but
also with XSL-FO 1.0.

The concept of "only" can be implemented in XSL-FO 1.0:


http://lists.renderx.com/pipermail/xep-support/2005-October/004318.html

... but, Jesper, I think you are missing something in Kevin's response: the content still goes into static content and not the body region. You will have to adjust the footer height to make it look like it is content. However, since your "continued" is still in the static content, it cannot appear as if it is inside your bordered table in the body content. If your table were not bordered, then the adjusted footer height would place the "continued" text looking as if it were the next line of the body.

So, with Kevin's insight (thank you, Kevin!), the stylesheet below is an implementation of "only" ... but it buys you nothing over my original solution for you that uses marker retrieval. Solving your problem with an "only" implementation is no better than solving your problem with marker retrieval, because both solutions are using static content.

As I said earlier, in XSL-FO 1.0 there is no way to retrieve marker content into the body region.

I hope this helps.

. . . . . . . . . Ken

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs" version="2.0">

<xsl:variable name="text_short" select="'Pellentesque non dui metus.'"/>

    <xsl:variable name="text_long"> Pellentesque non dui metus. Proin
felis urna, mattis iaculis
        ullamcorper sed, faucibus ut sem. Maecenas eleifend imperdiet
augue, et venenatis ipsum
        pellentesque id. Proin at convallis tortor. In sollicitudin
nulla ut eros condimentum cursus
        eu quis ante. Aliquam consectetur tincidunt fringilla.
Suspendisse vitae libero ac risus
        pellentesque lacinia a ut ipsum. Integer pretium nibh a lacus
ullamcorper in sodales leo
        congue. Vestibulum neque velit, sagittis nec sagittis id,
tincidunt id dui. Nam faucibus
        turpis eu velit luctus commodo. Nullam tempor felis et mi
commodo cursus. Aliquam
        sollicitudin ullamcorper venenatis. Phasellus venenatis,
tortor at lobortis adipiscing,
        velit turpis suscipit orci, at tempor dolor ligula nec magna.
Etiam ornare ullamcorper
        mauris, id gravida augue tempus sit amet. Pellentesque non dui
metus. Proin felis urna,
        mattis iaculis ullamcorper sed, faucibus ut sem. Maecenas
eleifend imperdiet augue, et
        venenatis ipsum pellentesque id. Proin at convallis tortor. In
sollicitudin nulla ut eros
        condimentum cursus eu quis ante. Aliquam consectetur tincidunt
fringilla. Suspendisse vitae
        libero ac risus pellentesque lacinia a ut ipsum. Integer
pretium nibh a lacus ullamcorper in
        sodales leo congue. Vestibulum neque velit, sagittis nec
sagittis id, tincidunt id dui. Nam
        faucibus turpis eu velit luctus commodo. Nullam tempor felis
et mi commodo cursus. Aliquam
        sollicitudin ullamcorper venenatis. Phasellus venenatis,
tortor at lobortis adipiscing,
        velit turpis suscipit orci, at tempor dolor ligula nec magna.
Etiam ornare ullamcorper
        mauris, id gravida augue tempus sit amet. Pellentesque non dui
metus. Proin felis urna,
        mattis iaculis ullamcorper sed, faucibus ut sem. Maecenas
eleifend imperdiet augue, et
        venenatis ipsum pellentesque id. Proin at convallis tortor. In
sollicitudin nulla ut eros
        condimentum cursus eu quis ante. Aliquam consectetur tincidunt
fringilla. Suspendisse vitae
        libero ac risus pellentesque lacinia a ut ipsum. Integer
pretium nibh a lacus ullamcorper in
        sodales leo congue. Vestibulum neque velit, sagittis nec
sagittis id, tincidunt id dui. Nam
        faucibus turpis eu velit luctus commodo. Nullam tempor felis
et mi commodo cursus. Aliquam
        sollicitudin ullamcorper venenatis. Phasellus venenatis,
tortor at lobortis adipiscing,
        velit turpis suscipit orci, at tempor dolor ligula nec magna.
Etiam ornare ullamcorper
        mauris, id gravida augue tempus sit amet.Pellentesque non dui
metus. Proin felis urna,
        mattis iaculis ullamcorper sed, faucibus ut sem. Maecenas
eleifend imperdiet augue, et
        venenatis ipsum pellentesque id. Proin at convallis tortor. In
sollicitudin nulla ut eros
        condimentum cursus eu quis ante. Aliquam consectetur tincidunt
fringilla. Suspendisse vitae
        libero ac risus pellentesque lacinia a ut ipsum. Integer
pretium nibh a lacus ullamcorper in
        sodales leo congue. Vestibulum neque velit, sagittis nec
sagittis id, tincidunt id dui. Nam
        faucibus turpis eu velit luctus commodo. Nullam tempor felis
et mi commodo cursus. Aliquam
        sollicitudin ullamcorper venenatis. Phasellus venenatis,
tortor at lobortis adipiscing,
        velit turpis suscipit orci, at tempor dolor ligula nec magna.
Etiam ornare ullamcorper
        mauris, id gravida augue tempus sit amet.Pellentesque non dui
metus. Proin felis urna,
        mattis iaculis ullamcorper sed, faucibus ut sem. Maecenas
eleifend imperdiet augue, et
        venenatis ipsum pellentesque id. Proin at convallis tortor. In
sollicitudin nulla ut eros
        condimentum cursus eu quis ante. Aliquam consectetur tincidunt
fringilla. Suspendisse vitae
        libero ac risus pellentesque lacinia a ut ipsum. Integer
pretium nibh a lacus ullamcorper in
        sodales leo congue. Vestibulum neque velit, sagittis nec
sagittis id, tincidunt id dui. Nam
        faucibus turpis eu velit luctus commodo. Nullam tempor felis
et mi commodo cursus. Aliquam
        sollicitudin ullamcorper venenatis. Phasellus venenatis,
tortor at lobortis adipiscing,
        velit turpis suscipit orci, at tempor dolor ligula nec magna.
Etiam ornare ullamcorper
        mauris, id gravida augue tempus sit amet. </xsl:variable>

<xsl:variable name="text" select="$text_long"/>

    <xsl:template name="start" match="/">
        <fo:root font-size="14pt">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="only"
page-height="297mm" page-width="210mm"
                    margin="1in 1in 1in 1in">
                    <fo:region-body margin-bottom="2cm + 1em"/>
                    <fo:region-after region-name="first_only"
                                     extent="2.3cm + 1em"/>
                </fo:simple-page-master>

<fo:simple-page-master master-name="first"
page-height="297mm" page-width="210mm"
margin="1in 1in 1in 1in">
<fo:region-body margin-bottom="2cm"/>
<fo:region-after region-name="first_first" extent="2.3cm"/>
</fo:simple-page-master>


                <fo:simple-page-master master-name="rest"
page-height="297mm" page-width="210mm"
                    margin="1in 1in 1in 1in">
                    <fo:region-body margin-bottom="2cm"/>
                    <fo:region-after region-name="rest_rest" extent="2.3cm"/>
                </fo:simple-page-master>

<fo:page-sequence-master master-name="document">
<fo:repeatable-page-master-alternatives maximum-repeats="1">
<fo:conditional-page-master-reference master-reference="only"
page-position="last"/>
<fo:conditional-page-master-reference master-reference="first"
page-position="first"/>
</fo:repeatable-page-master-alternatives>
<fo:repeatable-page-master-reference master-reference="rest"/>
</fo:page-sequence-master>


</fo:layout-master-set>

            <fo:page-sequence master-reference="document">
                <fo:static-content flow-name="first_only">
                    <fo:block border-top="1pt solid black"
margin-bottom="0.5em">First page only</fo:block>
                </fo:static-content>

                <fo:static-content flow-name="first_first">
                    <fo:block border-top="1pt solid black"
margin-bottom="0.5em">Continued over the next page</fo:block>
                </fo:static-content>

                <fo:static-content flow-name="rest_rest">
                    <fo:block border-top="1pt solid black"
margin-bottom="0.5em"/>
                    <fo:block>END of DOCUMENT</fo:block>
                </fo:static-content>

<fo:flow flow-name="xsl-region-body">

                    <fo:table border="1pt solid black">
                        <fo:table-header>
                            <fo:table-row>
                                <fo:table-cell>
                                    <fo:block font-size="16pt"
font-weight="bold"
                                        margin-bottom="0.5em">ITEMS:</fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-header>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell>
                                    <fo:block>
                                        <xsl:value-of select="$text"/>
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>


-- Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal


Current Thread
Keywords
xml