Definitive XSL-FO

7.3 Page Sequence Master Interleave (PSMI)

Sometimes it is necessary to change page geometry based on content.

  • Consider the need to change the geometry for a lengthy landscaped table.

    • You cannot use a rotated table because the table length is limited by the container.

    • You must switch to a landscape body region so the lengthy table can flow to subsequent pages.

  • Consider the need to flow certain figures into double- sized pages.

    • You must selectively choose a geometry with different dimensions.

  • The construct may be deep within the structure of the document being processed .

To use XSL-FO, you must package all content for each page geometry into the flow of a page sequence.

  • This can involve a difficult and wasteful recursive process

    • finding all information up to the change in geometry,

    • packaging the information into a page sequence,

    • packaging the special constructs into a different page sequence,

    • recursively finding all information up to the next change in geometry.

  • This breaks the XSLT model of hierarchical processing.

    • This approach is susceptible to development and maintenance problems.

A two-step process can make this very easy to implement.

  • The first step creates the flow with supplemental indications of the need to change geometries.

    • You can come from any depth of processing of the source document.

    • Block-level constructs of a page are the immediate children of the flow.

  • The second step repackages flow children in as many sequences as necessary.

    • It recursively checks all flow child constructs for any changes in geometry.

    • It is not necessary to check any depth deeper than the children.

  • The resulting document is then processed by a standard XSL-FO engine.

The Page Sequence Master Interleave (PSMI) semantic implements this algorithm.

  • The public resource is freely available from Crane Softwrights Ltd.

    • http://www.CraneSoftwrights.com/links/res-dxslfo.htm

  • A one-element vocabulary is designed to express the semantic of this two-step intermediate process.

  • An XSLT stylesheet implements the semantic for any XSL-FO+PSMI sequence.

Consider the need to flow a landscape table in a portrait page geometry, as shown in Figure 7-6. Here's how this is addressed using the PSMI.

  • You could rotate a short table in a block container to present it in landscape orientation.

    • A long table would overflow and not trigger a new page in pagination.

  • Using PSMI, you could flow the landscape table into an interleaved page geometry where the body region of that geometry is landscape.

  • The PSMI stylesheet reads the XSL-FO+PSMI instance and produces a pure XSL-FO instance where three page sequences are created instead of one.

  • A long table in the landscape body region will correctly trigger new pages in pagination.

Figure 7-6. Page Sequence Master Interleave (PSMI)

An example of flow implementing the change in page geometry is shown in Example 7-5.

Example 7-5 PSMI constructs in example

Line 01 <simple-page-master master-name="frame-portraitbody" ...> 02 <region-body region-name="frame-body" .../> 03 <region-before region-name="frame-before" .../> 04 <region-after region-name="frame-after" .../> 05 </simple-page-master> 06 <simple-page-master master-name="frame-landbody" ...> 07 <region-body region-name="frame-body" 08 reference-orientation="90deg" .../> 09 <region-before region-name="frame-before" .../> 10 <region-after region-name="frame-after" .../> 11 </simple-page-master> 12 ... 13 <page-sequence master-reference="frame-portraitbody"> 14 <flow flow-name="frame-body"> 15 <block>Portrait information</block> 16 ... 17 <block>Next is landscaped</block> 18 <psmi:page-sequence master-reference="frame-landbody" 19 xmlns:psmi="http://www.CraneSoftwrights.com/resources/psmi"> 20 <flow flow-name="frame-body"> 21 <table> 22 <table-body> 23 <table-row> 24 <table-cell border="solid"> 25 <block>This is a test</block> 26 <block>This is a test</block> 27 ... 28 <block>This is a test</block> 29 <block>This is a test</block> 30 </table-cell> 31 </table-row> 32 </table-body> 33 </table> 34 </flow> 35 </psmi:page-sequence> 36 <block>Back to portrait</block> 37 ... 38 </flow>

Категории