Line Numbering Extension for XEP 3.2

Table of Contents

1. Requirements
2. Model and Syntax
3. Use Example

1. Requirements

Line numbering cannot be achieved by standard XSL FO means, and requires a proprietary extension to XSL language. What follows is a description of one such extension, implemented by RenderX in XEP XSL FO formatter, version 3.2.

The following requirements had to be met by this extension:

2. Model and Syntax

Implementation uses one empty extension element: <rx:ruler>. Like all other XEP extensions to XSL 1.0 recommendation, it is placed into a separate namespace: xmlns:rx="http://www.renderx.com/XSL/Extensions".

This element must be first child of a <fo:block-container> element. It creates a vertical sequence of uniformly spaced consecutive numbers attached to the start-edge side of the parent block-container (left side for Western scripts).

Line numbers are put into a special block-area that extends to the whole height of the block-container in the block progression direction; we call it line-number-area. In the inline progression direction, its extent is constrained by the respective attributes on <rx:ruler>: inline-progression-dimension or width

Note:

The line-number-area overlays areas generated by its parent <fo:block-container> element, and does not affect formatting of the block-container contents. XSL FO formatters that don't support RenderX extensions can safely skip <rx:ruler> tags: layout of other elements should not be affected.

The line-number-area is then filled with line areas; each line contains a single number. Numbers are generated consecutively; number format is controlled by the same properties as for page numering. Separation between lines is set by line-height property on <rx:ruler>. Horizontal alignment of numbers within the line-number-area is governed by text-align trait on the same element.

The following attributes of <rx:ruler> element can be used to control presentation of the number sequence:

Inline progression dimension

Inline progression dimension of the line-number-area can be specified by standard attributes: inline-progression-dimension and its subcomponents, width, min-width, max-width, etc.

line-height

line-height sets vertical separation between two consecutive numbers.

text-align

text-align specifies horizontal alignment of numbers within the line-number-area. Supported values are "start"/"left" and "end"/"right".

Number format properties

The same properties that are used to set page number format can be applied to specify number progression for lines. These properties include format, grouping-separator, grouping-size, and letter-value. Their semantics is the same as on <fo:page-sequence>.

Font and character properties

The full set of inheritable font and character properties can be specified on <rx:ruler> to control font selection for the numbers: font-family, font-size, font-weight, font-style, etc.

3. Use Example

Here is a typical case for line numbering. Complete samples can be found in examples/linenumbering/ directory in XEP distribution.

<fo:block-container line-height="14pt"[1]
                    line-stacking-strategy="font-height"[2]>
    <rx:ruler font-size="9pt" font-family="Times" [3]
              text-align="end" width="30pt"[4]/>
    <fo:block start-indent="36pt"[5]>
      Text in this paragraph will be numbered.
      …
      …
      …
              
      

[1][2]

The combination of fixed-length line-height and line-stacking-strategy="font-height" ensures that separation between lines is constant, thus guaranteeing proper synchronization between text lines and line numbers regardless of font changes in the body of the text.

[3]

Attention: you should not use font shorthand attribute here (font="9pt Times") because it resets line-height and is likely to disrupt line number alignment.

[4]

Line numbers will be aligned to the right (text-align="end") on a line that is offset by 30 pt from the left edge of the block container area (width="30pt").

[5]

Text in the body of the <fo:block-container> is indented; otherwise, line numbers would overlap it.


© RenderX 2000-2001. All rights reserved.