From MobileRead
Jump to: navigation, search

XPGT is an XML stylesheet called a page template (XPGT) for Adobe Digital Editions. This is not supported on version 4 or later ADE which replaces it with ePub 3 constructions.


[edit] Overview

The Adobe Digital Editions viewer implements several layout extensions to EPUB format. These include:

  • Page Masters – specify XSL:FO page masters to add headers, footers and sidebars as well as multi column layout.
  • Dynamic Page Master Selection – choose the right page master based on the environment.
  • Dynamic Styling – style the document based on the environment (viewing area dimensions, default font size, device resolution, etc.)

These extensions are typically used together as a layout template and can be all packaged as an additional stylesheet.

[edit] Referencing XPGT

It can be referenced like any other stylesheet directly from an XHTML file:

<html xmlns=”http://www.w3.org/1999/xhtml”>
   <link rel=”stylesheet”

It can also be referenced from a CSS file:

@import url(template.xpgt);

The XPGT file is also declared in the OPF manifest and assigned media type “application/adobe-page-template+xml”. As you might have guessed from the media type, XPGT is using XML rather than CSS-like syntax.

[edit] XPGT Syntax

The file is laid out with two sections: the layout-master-set and the Style section.

<ade:template xmlns=”http://www.w3.org/1999/xhtml”

[edit] Page Master Definitions

This section contains one or more page master definitions (they are called simple page masters in XSL:FO). A page master defines a partitioning of the page’s surface space into a set of regions. Each region is an area which can be occupied by a flow. A flow is a sequence of flowable content – paragraphs, lists, images, tables, etc. A sample page master That defines a 2 column flow is shown below:

<fo:simple-page-master master-name=”two_column_head”>
<fo:region-before extent=”6em”/>
<fo:region-body column-count=”2” column-gap=”10pt”
 margin-bottom=”1em” margin-top=”6.2em”
 margin-left=”0.3em” margin-right=”0.3em”/>

[edit] Page Master Selection

Once the master flows are defined then there needs to be a section that specifies how to build a sequence of pages in the document using these previously defined page masters (possibly different masters for different pages). Again, XSL:FO mark-up is used. Several extensions are available to achieve dynamic effects.

    master-reference=”two_column_head” page-position=”first”

This section will “repeatedly choose the first acceptable page master from the list” as defined by the conditions.

[edit] Dynamic Styling

The final section describes styling rules that depend on the environment (dynamic styling). These rules work together with rules CSS stylesheets. The rules in the page template have higher priority (specificity in CSS terms). Therefore CSS stylesheets should be used to specify environment-neutral styling of the document and page template styling should be used for environment-specific styling.

Just like CSS rules, page template styling rules have a selector which determines a set of applicable elements and a set of properties that the rule assigns to the elements. Selector is specified using selector attribute using regular CSS syntax. Properties are specified using attributes with matching names. In addition, styling rule can contain a condition which determines if the rule should be applied given a particular environment. Here is an example:

<ade:styling-rule selector=”.ibox”
  condition=”{ade:page-width() > 22*ade:default-font-size()}”
  float=”left” width=”70%” margin-top=”0pt”
  margin-right=”0.5em” margin-bottom=”0pt” margin-left=”0pt”/>

This rule applies to all elements with class ”ibox”. It sets a number of properties (float, width, margins) of these elements. It is only applied when page width is greater than 22 times default font size.

[edit] Conditions

Conditions are specified using XPath expressions in curly braces. Here is a list of XPath extension functions to query the environment:

  • ade:page-width() - The width of the page in CSS pixels
  • ade:page-height() - The height of the page in CSS pixels
  • ade:page-aspect() - Page width divided by page height
  • ade:default-font-size() - Default font size in CSS pixels
  • ade:device-is-color()- True if the device supports color
  • ade:resolution() - Size of the inch in CSS pixels

[edit] EPUB Documents without Page Template

There are always going to be many ePub documents that do not choose to incorporate a specific page template. Indeed it is a goal that documents that do not wish to declare custom intentions with respect to page layout should not need to incorporate such markup. Obviously, a Reading System that supports the page template extension must be able to process such documents.

One strategy would be to render such documents in a single column, no matter how large the viewing area is and how small the font size is. This would mean that such documents would look quite ugly. So if no page template is specified Adobe Digital Editions 1.0 automatically switches to 2 columns when width is about 61.5em and to three column layout when width is 93em. Column gap is about 1.5em. These numbers may change in future.

[edit] For more information

See the Adobe ePUB best practices guide. http://www.adobe.com/devnet/digitalpublishing

Personal tools

MobileRead Networks