[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: Thu, 27 Sep 2012 15:42:49 -0400

At 2012-09-27 20:46 +0200, Jesper Tverskov wrote:
One final detail. At the moment both

<fo:retrieve-marker retrieve-class-name="continued"
retrieve-position="last-starting-within-page"/>
<fo:retrieve-marker retrieve-class-name="firstonly"
retrieve-position="last-starting-within-page"/>

are placed in fo:static-content inside page footer of first page. Works fine.

But the first of the two retrieve-markers should ideally be at the end
of the table in region body that continues over more than the first
page when "long". Like if a footer for that table could be turned on
but only shown for first page. Nice if "continued" looks like a label
inside the table that continues.

Right ... which is where I was starting from using retrieve-table-header earlier in the thread. Your comment then directed me to take it out of the body region and into a perimeter region.


I can see in the spec that we have different values for
"retrieve-position", but I must admit that I haven't seen the light
yet. All these concepts are new to me.

Any help, hints?

Add a table-footer with one cell and in that cell do the retrieval.


I hope the working example below 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="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>
                        <fo:conditional-page-master-reference
page-position="first"
                            master-reference="first"/>
                        <fo:conditional-page-master-reference
page-position="rest"
                            master-reference="rest"/>
                    </fo:repeatable-page-master-alternatives>
                </fo:page-sequence-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="document">
                <fo:static-content flow-name="first_first">
                    <fo:block border-top="1pt solid black"
margin-bottom="0.5em"/>
<!-- Jesper's requirement
                    <!-\- Here we should have a toogle -\->
                    <fo:block>Continued over the next page</fo:block>
                    <!-\- if ITEMS continue to second page -\->
                    <fo:block>First page only</fo:block>
                    <!-\- if ITEMS stay on first page -\->
-->
<!-- Ken's suggestion-->
                  <fo:block>
                    <fo:retrieve-marker retrieve-class-name="firstonly"
                        retrieve-position="last-starting-within-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-footer>
                            <fo:table-cell>
                              <fo:block>
                    <fo:retrieve-table-marker retrieve-class-name="continued"
                  retrieve-position-within-table="last-starting"/>
                              </fo:block>
                            </fo:table-cell>
                        </fo:table-footer>
                        <fo:table-body>
                            <fo:table-row>
                      <!--long table-->
                      <fo:marker marker-class-name="continued"
                        >Continued over the next page...</fo:marker>
                      <fo:marker marker-class-name="firstonly"/>
                                <fo:table-cell>
                                    <fo:block>
                                        <xsl:value-of select="$text"/>
                                    </fo:block>
                      <!--short table-->
                      <fo:block>
                        <fo:marker marker-class-name="continued"/>
                      </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>

                    <fo:block>
                      <!--the following markers are used for a short table-->
                      <fo:marker marker-class-name="firstonly"
                        >First page only</fo:marker>
                    </fo:block>

                </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