Stylesheet files

A stylesheet is defined by two XML files:

  • mappings.tlx contains the mappings

  • layout.xml contains the page layout information

[Note] Note

If your publication folder does not contain a mappings.tlx file, use the Commands » Stylesheet Upgrade menu item to upgrade to the new format.

The layout.xml file is edited using the layout editor. Changing this file manually is not recommended, since it contains measurements that must all be consistent to ensure correct results.

The mappings.tlx file is normally edited using the Mapping Editor. The next section contains information about this file to assist you if you need to change it manually.

A schema for mappings is installed in the sys\lib\mappings folder. This is provided as a convenience only. It is not used by TopLeaf to validate the mappings, so it should not be regarded as definitive.

By default the stylesheet files are placed in the publication folder. See “Sharing stylesheet files” for information about alternative locations.

Mappings Source Format

The mappings.tlx file contains an XML document with the following characteristics:

  • The root element is called mappings. It must contain a version attribute. The version value to use with the format described below is “1.1”. The other attributes are used internally by TopLeaf. You should not change any of these.

  • The first child element is called options and contains information about how the stylesheet will operate.

  • The mappings element may also contain an embedded typeface selection scheme as a child element.

  • The remaining child elements are called mapping and each one describes a separate tag, custom marker, header, footer or note mapping.

The order of mapping elements is not important, except that if there are duplicate mappings TopLeaf will use the last one encountered. Mappings are treated as duplicates if they have the same values for the path, type, predicate and occurs attributes.

The following sections describe the attributes that may be present on the mapping element and its children. The following attribute types may be used:

  • measure is a numeric value followed by a two-character unit specifier. The possible units are pt (points), cm (centimeters), mm (millimeters), in (inches), pc (picas) or dp (decipoints).

  • boolean may have the value yes or no. The values 1 and 0 may also be used. The default is no unless otherwise specified.

  • color is an RGB color specification. This can be one of the 16 standard color names or a string of the form “#RRGGBB” where each color component is a 2-digit hexadecimal number. If a color palette is defined for the stylesheet, one of the defined color names should be used.

Where the Mapping Editor allows a variable to be used to specify a value, the corresponding attribute may contain a variable name enclosed in {...}.

[Note] Note

TopLeaf does not validate the mappings.tlx file, so any attributes or elements with incorrect names will be ignored.

options element

Only one options element is allowed in the document. It must precede all of the mapping elements. The information in this element can be edited with the Format » Options dialog. Consult the documentation for this dialog for information on the attribute values.

Attribute Meaning
table-model One of CALS or HTML. If not present no table model is defined. When a table model is defined certain tag names are treated as defining table structure. These names cannot be configured and are always case-insensitive.
rule-width A measure defining the default width of rules.
hyphen-dict A boolean determining whether dictionary-based hyphenation is used.
hyphen-rules A boolean determining whether rule-based hyphenation is used.
language This is the numeric code of the default language. The value zero indicates English. Contact Turn-Key support for a list of language codes.
balance-cols A boolean determining whether column heights are equalized at a segment boundary.
run-build This optional element controls typesetting behavior for stylesheets created with older versions of TopLeaf. Consult Turn-Key support before making any changes to this attribute.
mapping element
Attribute Meaning
path This is the only mandatory attribute. It contains the tag-in-context value (including the page context) for tag and custom marker mappings, and the name for head/footer and note mappings.
type This identifies the type of mapping, and may be tag, custom, headfoot or note. The default value is tag.
predicate For tag or custom mappings, this contains the attribute selector expression.
occurs For tag or custom mappings, this contains the occurrence selector.
priority This is an integer between 1 and 5. The default value is 3. Mappings with priority 1 are tested first, followed by 2 and so on; the first matching mapping found will be used. For mappings with the same priority value the normal precedence rules apply.

The values of the path, type, predicate and occurs attributes together uniquely identify a mapping.

start element

The start child element contains values from the Start Tag tab of the Mapping Editor. It is only used for tag and custom mappings.

Attribute Meaning
class The mapping classification. One of block, inline, listitem or label. This attribute is mandatory for tag and custom mappings. The value is ignored for table structure tags.
listtype Only used for list items. One of bullet, circle, square, shadowbox, diamond, decimal, lalpha, ualpha, lroman, uroman, emdash or endash.
bind-prev A boolean for bind to previous paragraph.
conspace-above A boolean for consolidate space above.
cancel-merge A boolean for disable merge with previous.
bind A boolean for bind element content.
start-box A boolean for start box.
start-mrule A boolean for start margin rule.
new-page A boolean for a page break that starts a new page. This is deprecated; use page-break instead.
new-group A boolean for a new leaf group or leaf section (ignored if not full looseleaf). This is deprecated; use page-break instead.
page-type The name of the page type to select.
page-break One of next, odd, column or group corresponding to the Mapping Editor options Page, Leaf, Column and Group, respectively.
headers Determine if headers are displayed. Ignored unless the mapping forces a page break or page type change. One of honor, show, hideall or hideone.
footers Determine if footers are displayed. As for headers.
valign Control vertical justification of the page. Ignored unless the mapping forces a page break or page type change. One of top, bottom, center or spread.

The start element may contain a child element called rule-above if the mapping generates a horizontal line above. This can have the following attributes.

Attribute Meaning
width A measure determining the rule weight.
space A measure determining the space between the rule and the mapping content.
color The rule color.
end element

The end child element contains values from the End Tag tab of the Mapping Editor. It is only used for tag and custom mappings.

Attribute Meaning
bind-next A boolean for bind to following paragraph.
merge-next A boolean for merge with following paragraph.
conspace-below A boolean for consolidate space below.
end-box A boolean for end box.
end-mrule A boolean for end margin rule.
end-page A boolean for end page. This is deprecated; use page-break instead.
end-group A boolean for an end leaf group or leaf section (ignored if not full looseleaf. This is deprecated; use page-break instead.
end-part A boolean for end partition (ignored it not full looseleaf).
page-type The name of the page type to select.
page-break One of next, odd, column or group corresponding to the Mapping Editor options Page, Leaf, Column and Group, respectively.
cancel-tt The number of the data telltale to cancel (1–9), or all.
cancel-rh The number of the running head to cancel (1–5).
headers Determine if headers are displayed. Ignored unless the mapping forces a page break or page type change. One of honor, show, hideall or hideone.
footers Determine if footers are displayed. As for headers.
valign Control vertical justification of the page. Ignored unless the mapping forces a page break or page type change. One of top, bottom, center or spread.

The end element may contain a child element called rule-below if the mapping generates a horizontal line below. This can have the following attributes.

Attribute Meaning
width A measure determining the rule weight.
space A measure determining the space between the rule and the mapping content.
color The rule color.
content element

The content child element contains values from the Content tab of the Mapping Editor.

Most of the attributes are ignored if scan is not yes.

Attribute Meaning
scan A boolean determining whether the element content is stored.
suppress A boolean determining whether the content is not rendered.
runhead The number of the running head (1–5) to which the content is assigned.
telltale The number of the data telltale (1–9) to which the content is assigned.
toc The number of the table of contents level (1–9) to which the content is assigned.
toc-suppress A comma-separated list of element names to be removed from the toc content. Currently used only by secondary transforms.
index The number of the index level (1–9) to which the content is assigned, or xref to assign it to XREF.
col-footnote A boolean for assigning the content to a column footnote.
page-footnote A boolean for assigning the content to a page footnote.
sidenote A boolean for assigning the content to a side note.
link-attr The name of the attribute used to create a link from the content.
target-attr The name of the attribute whose value is used to create a link target.
content The content model to use for reading the element content. One of default, element, mixed or preserve-space.
para element

The para child element contains values from the Paragraph tab of the Mapping Editor.

These are ignored for inline mappings and for table structure tags other than those that define a table cell.

Attribute Meaning
align The paragraph alignment. One of left, right, center or justify. For head/foot mappings may also be inside or outside.
before-space A measurement for the space before (above) the paragraph.
after-space A measurement for the space after (below) the paragraph.
left-margin A measurement for the left margin.
right-margin A measurement for the right margin.
first-indent A measurement for the first/left indent.
last-indent A measurement for the last/right indent.
label-offset A measurement for the label offset. Ignored unless the classification is listitem or label, or this is a footnote body mapping..
label-type The type of label. One of normal or dropped. Ignored unless the classification is label.
label-mingap A measurement for the minimum gap after a dropped label.
label-mindepth A measurement for the minimum depth of a dropped label.
reset-margins A boolean for ignoring the current left and right margins.
last-align The alignment of the last line in a paragraph. The values are as for align.
single-align The alignment used when the paragraph consists of a single line. The values are as for align.
iws The interword space when defined by a variable. See note below.
miniws A number giving the minimum interword space as a percentage of the font size. See note below.
maxiws A number giving the maximum interword space as a percentage of the font size. See note below.
widow-orphan A number, or two numbers separated by / specifying the minimum number of lines allowed at the bottom and top of a page, respectively. May also be the string any or none.
before-space-boundary The retention rule for before space. One of discard, intbound or retain.
after-space-boundary The retention rule for after space. One of discard, intbound or retain.
direction The paragraph reading direction. One of ltr or rtl.
vertical-align Sets the vertical alignment for header/footer content. One of top, middle or bottom.
[Note] Note

When the interword space is defined both the miniws and maxiws attributes must be present.

If the interword space is defined by a variable, use the iws attribute and omit the miniws and maxiws attributes.

font element

The font child element contains values from the Font tab of the Mapping Editor.

Font attributes identified as tri-state have three possible values: on, off or inherit (the default). For these attributes, yes and no have the same meaning as on and off, respectively.

Attribute Meaning
typeface The name of the typeface or typeface selection scheme.
size A measurement for the font size. This must be present in the $document mapping.
leading A measurement for the font leading. This must be present in the $document mapping.
baseline A number giving the baseline shift as a percentage.
char-space A number giving the character spacing. This is a positive or negative integer expressed in thousandths of the current font size.
letter-space A number giving letter spacing as a percentage. This is deprecated; use char-space instead.
scale A number giving the horizontal scaling value as a percentage, where 100 is normal scaling.
italic A tri-state value for italic style.
bold A tri-state value for bold weight.
small A tri-state value for small size.
super A tri-state value for superscript.
sub A tri-state value for subscript.
lowercase A tri-state value for transform to lower case.
uppercase A tri-state value for transform to upper case.
underline A tri-state value for underlined.
reverse A tri-state for reversed foreground and background colors.
frame A tri-state for boxed text.
strikeout A tri-state for strike through.
overbar A tri-state for line drawn over the text.
kern-pairs A tri-state that determines whether kerning pair information in the font is used to adjust the space between characters.
color The text color. This must be present in the $document mapping.
hyphen-mode The hyphenation mode. One of off, emergency or normal.
hyphen-type The type of hyphenation split points used. One of explicit, good or poor.
[Note] Note

The hyphenation mode was formerly controlled by a single attribute called hyphenation. The corresponding new attribute values are:

  • For hyphenation="full" use hyphen-mode="normal" and hyphen-type="good".

  • For hyphenation="soft" use hyphen-mode="normal" and hyphen-type="explicit".

  • For hyphenation="none" use hyphen-mode="off".

table-style element

The table-style child element contains values from the Tables tab of the Mapping Editor.

Attribute Meaning
frame-style The table frame style. One of normal, bold or double.
frame-type The type of table frame to draw. One of all, top, bottom, topbot, sides or none.
top-margin A measurement for the space above the table.
bottom-margin A measurement for the space below the table.
left-margin A measurement for the space to the left of the table.
cell-top A measurement for the top cell indent.
cell-bottom A measurement for the bottom cell indent.
cell-sides A measurement for the cell side indents.
col-sep A boolean for the default column separator. This defaults to yes if not present.
row-sep A boolean for the default row separator. This defaults to yes if not present.
page-sep A boolean for whether to draw the page break separator. This defaults to yes if not present.
rule-width A measurement for the width of table rules.
rule-color The color of table rules.
bind-prev A boolean for bind to current paragraph.
reset-margins A boolean for ignoring the current left and right margins. This defaults to yes if not present.

The table-style element may contain child elements called head and body to define the style of header and body rows. These elements can have the following attributes.

Attribute Meaning
font-style The font style for text. One of normal, bold, italic or bolditalic.
fill-color The background color for cells.
box-style element

The box-style child element contains values from the Box tab of the Mapping Editor.

Attribute Meaning
frame-style The table frame style. One of normal, double or shadow.
frame-type The type of table frame to draw. One of top, bottom, topbot, all, sides, none, left, right, sidetop or sidebot.
fixed-depth A measurement to set a fixed depth for the box.
top-margin A measurement for the space above the box.
bottom-margin A measurement for the space below the box.
left-margin A measurement for the space to the left of the box.
right-margin A measurement for the space to the right of the box.
text-top A measurement for the top indent. Defaults to 6pt if not present. Must be present in the $document mapping.
text-bottom A measurement for the bottom indent. Defaults to 6pt if not present. Must be present in the $document mapping.
text-sides A measurement for the side indents. Defaults to 6pt if not present. Must be present in the $document mapping.
breakable A boolean for whether this box can break across a page.
page-sep A boolean for whether to draw the page break separator.
reset-margins A boolean for ignoring the current left and right margins.
rule-width A measurement for the weight of the box frame rules.
rule-color The color of the box frame rules.
fill-color The background color of the box.
image element

The image child element contains values from the Image tab of the Mapping Editor.

Attribute Meaning
attribute The name of the attribute defining the image location.
path The path used to locate the image.
width A measurement for the maximum image width.
depth A measurement for the maximum image depth.
scale A number for the scale of the image as a percentage.
rotate A number for the image rotation in degrees.
defdpi A number for the default resolution in dots per inch.
mindpi A number for the minimum resolution in dots per inch.
custom-pre and custom-post elements

These two elements contain the content of the two fields on the Custom tab. They both contain character data.

convert element

This element contains style overrides for secondary output formats. It is ignored by the composition engine when creating paged output.