Markers

1. Markers
2. Static content dependant on page content
3. Section X continued.

1.

Markers

Wendell Piez



question is how would I use XSL to "modify" or "repopulate" markers
>whenever the pages "hit" (or are incident upon) content from the "next"
>chapter.

If a new chapter starts and a new marker is presented to the formatter, it knows how to do the modification on the pages. (That's what markers are for.)

Your solution is as easy as:

<xsl:template match="chapter">
   <fo:block>
     <fo:marker marker-class-name="chapter-title">
        <xsl:apply-templates select="title" mode="header"/>
     </fo:marker>
     <xsl:apply-templates/>
   </fo:block>
<xsl:template>

Each chapter gets a marker with its own title in it; the fo:retrieve-marker (which refers to this marker class), placed into the static content (that is, the header), then updates itself. That job is done by the formatter; as long as the marker is there, your XSLT doesn't have to do anything else.

2.

Static content dependant on page content

Mike Grimley


> Actually every following block-container will eclipse previous one in
> the order of retrieve-markers. So I suppose you have first
> retrieve-marker with class 'unchanged' and second retrieve-marker with
> class 'changed' - in this case the latter one will mask the former
> one. I believe that in such a way you can achieve required
> functionality without any z-indexes with any number of classes.

So, what's the code?

Because I simply have a choice of two, I have the block displaying 'Unchanged' by default. I only set the marker if the status of an instruction is 'Changed'. If there is a 'Changed' marker, it simply covers the default.

<fo:static-content flow-name="EvenPage-header">
  <fo:block-container height="30pt" 
	  position="fixed" top="2.5pc" text-align="center">
   <fo:block xsl:use-attribute-sets="Status">Unchanged</fo:block>
	</fo:block-container>
	<fo:block-container height="30pt" 
          position="fixed" top="2.5pc" text-align="center">
	 <fo:retrieve-marker retrieve-class-name="Status" 
         retrieve-position="first-including-carryover" 
         retrieve-boundary="page"/>
      </fo:block-container>
</fo:static-content>

This offers a defined alternative:

Markers:

  <fo:marker marker-class-name="unchanged">
    <fo:block-container position="absolute" 
         top="0.5in" left="1in" width="2in" height="0.5in" 
         background-color="white">
      <fo:block>**unchanged**</fo:block>
    </fo:block-container>
  </fo:marker>
  
  or
  
  <fo:marker marker-class-name="changed">
    <fo:block-container position="absolute" top="0.5in" 
          left="1in" width="2in" height="0.5in" 
           background-color="white">
      <fo:block>++changed++</fo:block>
    </fo:block-container>
  </fo:marker>

and Static content:

  <fo:static-content flow-name="xsl-region-before">
      <fo:retrieve-marker retrieve-class-name="unchanged" 
                retrieve-position="first-including-carryover" 
                retrieve-boundary="page"/>
      <fo:retrieve-marker retrieve-class-name="changed" 
             retrieve-position="first-including-carryover" 
             retrieve-boundary="page"/>
  </fo:static-content>


> Does one have to have fo:retrieve-markers in the order of 
>  accending precedence?

Yes.

> Then if there is a marker to retrieve the latest retrieved will generate an
> absolute container on top of the rest?

Yes.

3.

Section X continued.

Ken Holman


> I'm using a retrieve-marker in an xsl-region-before in the hope of
> showing a 'section X continued' label when page breaks occur within
> certain blocks or block-containers. Since there's no such thing as a
> "first-within-carryover" value for the retrieve-position attribute,
> is there any way to do this without sometimes grabbing the first
> marker in the current page?

It sounds like you are not "undoing" the marker at the beginning and end of your sensitive blocks or containers.

> As it is, I'm using "first-including-carryover" so if the page break
> occurs between blocks, there is no carryover and the first marker in
> the current page displays. As it should, per the spec, but not per my
> intent. Does anyone know of a workaround?

Yes, but doing it for a header is not as straightforward as doing it for a footer.

Here is an example where I'm putting "continued..." at the bottom of a page in a footer:

  <block>
     <marker marker-class-name="section">Section One - 1.</marker>
     <marker marker-class-name="continued">(continued...)</marker>
     <block>1. Section One</block>
     <block space-before="1em">This is a test</block>
     ...
     <block space-before="1em">This is a test</block>
   </block>
   <block>
     <marker marker-class-name="continued"></marker>
   </block>
   <block space-before="2em">
     <marker marker-class-name="section">Section Two - 2.</marker>
     <marker marker-class-name="continued">(continued...)</marker>
     <block>2. Section Two</block>
     <block space-before="1em">This is a test</block>
     ...
     <block space-before="1em">This is a test</block>
   </block>
   <block>
     <marker marker-class-name="continued"></marker>
   </block>

In fact this undoing of the marker would be important for you regardless, because what if the block you have ends right at the very bottom of the page? There is always room for an empty block at the bottom of the page. If your table ends right at the bottom, then you don't want the marker defined for the bottom of that page or the top of the next.

BTW, the kind of retrieval you need for a footer is the last within the page:

   <static-content flow-name="frame-after">
     <block text-align="end" font-style="italic" font-size="12pt">
       <retrieve-marker retrieve-class-name="continued"
                   retrieve-position="last-starting-within-page"/>
     </block>
   </static-content>

But what you need is a marker retrieved into the header and that is more subtle. First, you have to be prepared for a block starting at the very top of the page (where you do not want it to show), which means you have to both make sure it is not defined (that is, defined as empty) as the first block on the page, and then define it as part of the block. *Then* you have to undefine it at the end again so that the definition isn't lying around to be retrieved on the next page.

Here is code that works for "...continued" in the header:

   <static-content flow-name="frame-before">
     <block text-align="end" font-style="italic" font-size="12pt">
       <retrieve-marker retrieve-class-name="continued"
                   retrieve-position="first-including-carryover"/>
     </block>
   </static-content>
   ...
   <block keep-with-next="always">
     <marker marker-class-name="continued"></marker>
   </block>
   <block>
     <marker marker-class-name="section">Section One - 1.</marker>
     <marker marker-class-name="continued">(...continued)</marker>
     <block>1. Section One</block>
     <block space-before="1em">This is a test</block>
     <block space-before="1em">This is a test</block>
     ...
     <block space-before="1em">This is a test</block>
     <block space-before="1em">This is a test</block>
   </block>
   <block keep-with-previous="always">
     <marker marker-class-name="continued"></marker>
   </block>

Note how my use of keeps will ensure the empty definition is on the same page and before the non-empty definition, thus ensuring the first one on the page is the empty definition.

Since you are pulling into the header, your use of "first including carryover" is appropriate since the marker would have been undone if the table ended on the page before.