<?xml version="1.0" encoding="utf-8"?>
<spec>
<header>
<title>Extensible Stylesheet Language (XSL)</title>
<version>Version 1.0</version>
<w3c-designation>xsl-20011015</w3c-designation>
<w3c-doctype>W3C Recommendation</w3c-doctype>
<pubdate><day>15</day><month>October</month><year>2001</year></pubdate>
<publoc>
<loc href="http://www.w3.org/TR/2001/REC-xsl-20011015/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/2001/REC-xsl-20011015/</loc>
<otherversions>
<loc href="http://www.w3.org/TR/2001/REC-xsl-20011015/xslspecRX.pdf" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">PDF by RenderX</loc>,
<loc href="http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.xml" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">XML file</loc>,
<loc href="http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">HTML (one large file)</loc>,
<loc href="http://www.w3.org/TR/2001/REC-xsl-20011015/xs011015.zip" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">ZIP file</loc>
</otherversions>

</publoc>
<latestloc>
<loc href="http://www.w3.org/TR/xsl/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/xsl/</loc>
</latestloc>
<prevlocs>
<loc href="http://www.w3.org/TR/2001/PR-xsl-20010828/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/2001/PR-xsl-20010828/</loc>
</prevlocs>
<authlist>
<author>
<name>Sharon Adler</name>
<affiliation>IBM</affiliation>
<email href="mailto:sca@us.ibm.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">sca@us.ibm.com</email>
</author>
<author>
<name>Anders Berglund</name>
<affiliation>IBM</affiliation>
<email href="mailto:alrb@us.ibm.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">alrb@us.ibm.com</email>
</author>
<author>
<name>Jeff Caruso</name>
<affiliation>Pageflex</affiliation>
<email href="mailto:jcaruso@pageflexinc.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">jcaruso@pageflexinc.com</email>
</author>
<author>
<name>Stephen Deach</name>
<affiliation>Adobe</affiliation>
<email href="mailto:sdeach@adobe.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">sdeach@adobe.com</email>
</author>
<author>
<name>Tony Graham</name>
<affiliation>Sun</affiliation>
<email href="mailto:Tony.Graham@ireland.sun.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">Tony.Graham@ireland.sun.com</email>
</author>
<author>
<name>Paul Grosso</name>
<affiliation>Arbortext</affiliation>
<email href="mailto:paul@arbortext.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">paul@arbortext.com</email>
</author>
<author>
<name>Eduardo Gutentag</name>
<affiliation>Sun</affiliation>
<email href="mailto:eduardo.gutentag@eng.sun.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">eduardo.gutentag@eng.sun.com</email>
</author>
<author>
<name>Alex Milowski</name>
<email href="mailto:alex@milowski.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">alex@milowski.com</email>
</author>
<author>
<name>Scott Parnell</name>
<affiliation>Xerox</affiliation>
<email href="mailto:Scott.Parnell@usa.xerox.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">Scott.Parnell@usa.xerox.com</email>
</author>
<author>
<name>Jeremy Richman</name>
<email href="mailto:JeremyRichman@compuserve.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">JeremyRichman@compuserve.com</email>
</author>
<author>
<name>Steve Zilles</name>
<affiliation>Adobe</affiliation>
<email href="mailto:szilles@adobe.com" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">szilles@adobe.com</email>
</author>
</authlist>

<status>

<p><emph>This section describes the status of this document at the
time of its publication. Other documents may supersede
this document. The latest status of this series of
documents is maintained at the W3C.</emph></p>

<p>This document has been reviewed by W3C
Members and other interested parties and has
been endorsed by the Director as a W3C
Recommendation. It is a stable document and may
be used as reference material or cited as a
normative reference from another document.
W3C's role in making the Recommendation is to
draw attention to the specification and to promote
its widespread deployment. This enhances the
functionality and interoperability of the Web.</p>

<p>This document has been produced as part of the <loc href="http://www.w3.org/Style/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">W3C Style Activity</loc> by
the <loc href="http://www.w3.org/Style/XSL/Group/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">XSL Working Group</loc>
(<loc href="http://cgi.w3.org/MemberAccess/AccessRequest" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">members only</loc>).</p>

<p>General public discussion of XSL takes place
on the <loc href="http://www.mulberrytech.com/xsl/xsl-list/index.html" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">XSL-List</loc>
mailing list.</p>

<p>Please report errors in this document
to <loc href="mailto:xsl-editors@w3.org" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">xsl-editors@w3.org</loc>. <loc href="http://lists.w3.org/Archives/Public/xsl-editors/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">Archives</loc>
of the comments are available.
The list of known errors in this specification is available at <loc href="http://www.w3.org/2001/10/REC-XSL-20011015-errata" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/2001/10/REC-XSL-20011015-errata</loc>.
Some text in the property definitions has been copied from the CSS2
Recommendation and the list of errors in this specification is
available at <loc href="http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata.html" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata.html</loc>.
</p>

<p>A list of current W3C Recommendations and other technical documents
can be found at
<loc href="http://www.w3.org/TR/" show="replace" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/</loc>.</p>

</status>

<abstract>

<p>This specification defines the features and syntax for
the Extensible Stylesheet Language (XSL),
a language for expressing stylesheets. It consists of two
parts:</p>

<olist>

<item><p>a language for transforming XML documents, and</p></item>

<item><p>an XML vocabulary for specifying formatting
semantics.</p></item>

</olist>

<p>An XSL stylesheet specifies the presentation of a class of XML
documents by describing how an instance of the class is transformed
into an XML document that uses the formatting vocabulary.</p>

</abstract>

<langusage>
<language id="EN">English</language>
<language id="ebnf">EBNF</language>
</langusage>
<revisiondesc>
<slist>
<sitem>See RCS log for revision history.</sitem>
</slist>
</revisiondesc>
</header>
<body>


<div1><head>Introduction and Overview</head>
<p>
This specification defines the Extensible Stylesheet Language
(XSL). XSL is a language for expressing stylesheets. Given a class of
arbitrarily structured XML <bibref ref="XML"/>
documents or data files, designers use
an XSL stylesheet to express their intentions about how that
structured content should be presented; that is, how the source
content should be styled, laid out, and paginated onto some
presentation medium, such as a window in a Web browser or a
hand-held device, or a set of
physical pages in a catalog, report, pamphlet, or book.
</p>
<div2><head>Processing a Stylesheet</head>
<p>
An XSL <term>stylesheet processor</term> accepts a document
or data in XML
and an XSL stylesheet and produces the presentation of that XML source
content that was intended by the designer of that
stylesheet. There are two aspects of this
presentation process:
first, constructing a result tree from the XML source tree and second,
interpreting the result tree to produce formatted
results suitable for presentation on a
display, on paper, in speech, or onto other media. The first
aspect is called <term>tree transformation</term> and the
second
is called <term>formatting</term>. The process of formatting
is performed by the <term>formatter.</term> This formatter
may simply be a rendering engine inside a browser.
</p>
<p>
Tree transformation allows the structure of the result tree to be significantly
different from the structure of the source tree. For example, one could add
a table-of-contents as a filtered selection of an original source document,
or one could rearrange source data into a sorted tabular presentation.
In constructing the result tree,
the tree transformation process also adds the information necessary to
format that result tree.
</p>
<p>Formatting is enabled by including formatting semantics
in the result tree. Formatting semantics are
expressed in terms of a catalog of classes of
<term>formatting
objects.</term> The nodes of the result tree are formatting
objects. The classes of formatting objects
denote typographic abstractions such as page, paragraph,
table, and so
forth. Finer control over the presentation of these abstractions is
provided by a set of formatting properties, such as
those controlling indents, word- and
<spot id="jm010109_7ah"/>letter spacing, and widow, orphan, and hyphenation control.
In XSL, the
classes of <term>formatting objects</term> and
<term>formatting properties</term>
provide the vocabulary for expressing presentation intent.
</p>
<p>
The XSL processing model is intended to be
conceptual only.  An implementation is not
mandated to provide these as separate
processes.  Furthermore, implementations are free to process
the source document in any way that produces the same result
as if it were processed using the conceptual XSL processing
model.  A diagram depicting the detailed conceptual model is
shown below.<spot id="aj000035_1"/></p>
<figure>
<graphic source="two-process.gif" alt="The XSL two processes: transformation and formatting" longdesc="Diagram of XSL conceptual model, showing a source tree, transformed in a result tree with new element and attribute nodes, itself rendered by the XSL formatting on devices including printers, a cell phone and a Web browser." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>XSL Two Processes: Transformation &amp; Formatting</p></figcap>
</figure>
<div3><head>Tree Transformations</head>
<p>
Tree transformation constructs the result tree.  In XSL,
this tree is called the <term>element and attribute
tree,</term> with objects primarily in the
"formatting object" namespace. In this tree, a formatting
object
is represented as an XML element, with the properties represented by a
set of XML attribute-value pairs. The content of the formatting object
is the content of the XML element. Tree
transformation is defined in the XSLT Recommendation
<bibref ref="XSLT"/>.
A diagram depicting this conceptual process is
shown below.</p>
<figure>
<graphic source="tree1-2.gif" alt="The XSL Transformation process" longdesc="Detail of the previous diagram, showing the conceptual source and result trees, and describing that the transformation process can produce a result tree that has a quite different structure than that of the source tree." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Transform to Another Vocabulary</p></figcap>
</figure>
<p>
The XSL stylesheet is used in tree transformation. A stylesheet
contains a set of tree construction rules. The tree construction rules
have two parts: a pattern that is matched against elements in the
source tree and a template that constructs a portion of the result
tree. This allows a stylesheet to be applicable to a wide class of
documents that have similar source tree structures.
</p>
<p><spot id="wai_1"/>In some implementations of XSL/XSLT,
the result of tree construction
can be output as an XML document. This would allow an XML document
which contains formatting objects and formatting properties to be
output. This capability is neither necessary for an XSL processor nor
is it encouraged. There are, however, cases where this is important,
such as a server preparing input for a known client; for example, the way
that a WAP
(<xspecref href="http://www.wapforum.org/faqs/index.htm" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.wapforum.org/faqs/index.htm</xspecref>)
server prepares specialized input for a WAP capable
hand held device. To preserve accessibility, designers of Web systems
should not develop architectures that require (or use) the
transmission of documents containing formatting objects and properties
unless either the transmitter knows that the client can accept
formatting objects and properties or the transmitted document contains
a reference to the source document(s) used in the construction of the
document with the formatting objects and properties.
</p>
</div3>
<div3><head>Formatting</head>
<p>
Formatting interprets the result tree in its formatting object tree
form to produce the presentation intended by the designer
of the stylesheet from which the XML element and attribute
tree in the "fo" namespace was constructed.
</p>
<p>
The vocabulary of formatting objects supported by XSL - the set of
<code>fo:</code> element types - represents the set of
typographic abstractions available to the
designer. Semantically, each formatting object represents a
specification for a part of the pagination, layout, and styling
information that will be applied to the content of that formatting
object as a result of formatting the whole result tree. Each
formatting object class represents a particular kind of formatting
behavior. For example, the block formatting object class represents
the breaking of the content of a paragraph into lines. Other parts of
the specification may come from other formatting objects; for
example, the formatting of a paragraph (block formatting
object)
depends on both the specification of properties on the block
formatting object and the specification of the layout structure into
which the block is placed by the formatter.
</p>
<p>
The properties associated with an instance of a formatting object
control the formatting of that object. Some of the properties, for
example "color", directly specify the formatted result.
Other properties, for example 'space-before', only constrain the set
of possible formatted results without specifying any particular
formatted result. The formatter may make choices among other
possible considerations such as esthetics.
</p>
<p>
Formatting consists of the generation of a tree
of geometric areas, called the <term>area tree</term>. The
geometric areas are
positioned on a sequence of one or more pages (a browser typically
uses a single page). Each geometric area has a position on the page, a
specification of what to display in that area and may have a
background, padding, and borders. For example, formatting a
single
character generates an area sufficiently large enough to hold the
glyph that is used to present the character visually and the glyph is
what is displayed in this area. These areas may be nested. For
example, the glyph may be positioned within a line, within a
block, within a page.
</p>
<p>
Rendering
takes the area tree, the abstract model of the presentation (in terms
of pages and their collections of areas), and causes a
presentation to appear on the relevant medium, such as a browser
window on a computer display screen or sheets of paper. The semantics
of rendering are not described in detail in this specification.
</p>
<p>
The first step in formatting is to "objectify" the element
and attribute
tree obtained via an XSLT transformation.
Objectifying the tree basically consists of turning the
elements in the
tree into formatting object nodes and the
attributes into property specifications. The result of this step is
the <term>formatting object tree</term>.
</p>
<figure>
<graphic source="tree2-3.gif" alt="Objectification of the FO tree" longdesc="Diagram showing how the Formatting Objects tree is 'objectified': new nodes are created as characters are converted to character FOs." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Build the XSL Formatting Object Tree</p></figcap>
</figure>
<p>
As part of the step of objectifying, the characters that occur in
the result tree are replaced by fo:character nodes.
<spot id="fo_12"/>Characters in text nodes which consist
solely of <spot id="jm010109_7bf"/>white space characters and
which are children of elements whose corresponding formatting objects do
not permit fo:character nodes as children are ignored.  Other characters
within elements whose corresponding formatting objects do not permit
fo:character nodes as children are errors.

</p>
<p><spot id="fo01jr_3c"/>The content of the fo:instream-foreign-object
is not objectified;
instead the object representing the fo:instream-foreign-object
element points to the appropriate node in the element and
attribute tree.
<spot id="wai_4f"/>Similarly any non-XSL namespace child element
of fo:declarations is not objectified; instead the object representing
the fo:declarations element points to the appropriate node in the
element and attribute tree.
</p>
<p>
The second phase in formatting is to refine the formatting
object tree
to produce the <term>refined formatting object tree</term>.
The refinement process handles the mapping from properties
to traits.  This consists of: (1) shorthand expansion into
individual properties, (2) mapping of corresponding
properties, (3) determining computed values (may include
expression evaluation),
(4) handling white-space-treatment and linefeed-treatment
property effects, and (5) inheritance.
Details on
refinement are found in <specref ref="refinement"/>.
</p>
<p>The refinement step is depicted in the diagram below.
</p>
<figure>
<graphic source="tree3-4.gif" alt="Refinement of the FO tree" longdesc="Diagram showing the refinement process of the FO tree: traits are computed from properties using the inheritance model and evaluation of expressions." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Refine the Formatting Object Tree</p></figcap>
</figure>
<p>
The third step in formatting is the construction of the area
tree. The
area tree is generated as described in the semantics of each
formatting object. The traits applicable to each formatting
object
class control how the areas are generated. Although every
formatting property may be specified on every formatting object, for
each formatting object class, only a subset of the formatting
properties are used to determine the traits for objects of
that class.
</p>
<p>Area generation is depicted in the diagram below.<spot id="aj000035_2"/>
</p>
<figure>
<graphic source="trees4-5.gif" alt="Area tree generation" longdesc="This figure shows the last step in the XSL process: a source tree of FOs transforms into a result tree of areas which is rendered on various devices (printer, phone, screen)." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Generate the Area Tree</p></figcap>
</figure>
<figure>
<graphic source="process-sum.gif" alt="FO-to-area process summary" longdesc="This diagram summarizes the XSL process for a sample formatting object block and two attributes: objectification turns the block element to the block FO and its attributes into properties. After refinement, properties become traits (units are normalized), and the last step makes a block area from the block FO." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Summary of the Process</p></figcap>
</figure>
</div3>
</div2>
<div2><head>Benefits of XSL</head>
<p>Unlike the case of HTML, element names in XML have no intrinsic
presentation semantics. Absent a stylesheet, a processor could not
possibly know how to render the content of an XML document other
than as an undifferentiated string of characters. XSL provides
a comprehensive model and a vocabulary for writing such stylesheets using XML syntax.
</p>
<p>
This document is intended for implementors of such XSL processors.
Although it can be used as a reference manual for writers of XSL
stylesheets, it is not tutorial in nature. </p>
<p>
XSL builds on the prior work on Cascading Style Sheets
<bibref ref="CSS2"/> and
the Document Style Semantics and Specification Language
<bibref ref="DSSSL"/>.
While many of XSL's formatting objects and properties correspond
to the common set of properties, this would not be
sufficient by
itself to accomplish all the goals of XSL. In particular, XSL introduces
a model for pagination and layout that extends what is currently available
and that can in turn be extended, in a straightforward way, to page
structures beyond the simple page models described in this specification.
</p><div3><head>Paging and Scrolling</head>
<p>Doing both scrollable document windows and pagination introduces
new complexities to the styling (and pagination) of XML content.
Because pagination introduces arbitrary boundaries
(pages or regions on pages) on the content, concepts such as
the control
of spacing at page, region, and block boundaries become
extremely important. There are also concepts related to
adjusting the spaces between lines (to adjust the page
vertically)
and between words and letters (to justify the lines of text).
These do not always arise with simple scrollable document
windows, such as those found in today's browsers. However, there
is a correspondence between a page with multiple regions, such as a body,
header, footer, and left and right <spot id="c11i14_a"/>sidebars, and a Web
presentation using "frames". The distribution of content into the regions
is basically the same in both cases, and XSL handles both
cases in an analogous fashion.</p>
<p>
XSL was developed to give designers control over the features
needed when documents are paginated as well as to provide an
equivalent "frame" based structure for browsing on the Web.
To achieve this control, XSL has extended the set of formatting
objects and formatting properties. In addition, the selection
of XML source components that can be styled (elements,
attributes, text nodes, comments, and processing
instructions) is based on XSLT and
XPath <spot id="jm010109_28"/><bibref ref="XPATH"/>,
thus providing the
user with an extremely powerful selection mechanism. </p>
<p>
The design of the formatting objects and properties extensions
was first inspired by DSSSL. The actual extensions, however, do not
always look like the DSSSL constructs on which they were based. To either
conform more closely with the CSS2 specification or to
handle cases more simply than in DSSSL, some extensions have diverged from DSSSL.
</p><p>
There are several ways in which extensions were made. In some cases,
it sufficed to add new values, as in the case of those added to reflect
a variety of writing-modes, such as top-to-bottom and bottom-to-top, rather
than just left-to-right and right-to-left.
</p><p>
In other cases, common properties that are expressed in CSS2
as one property with multiple simultaneous values, are split into
several new properties to provide independent control over independent
aspects of the property. For example, the "white-space" property was
split into four properties:
a <spot id="od000138_2b"/>"white-space-treatment" property that
controls how <spot id="jm010109_7be"/>white space is processed, a <spot id="aj000035_3"/>"linefeed-treatment" property that controls
how <spot id="jm010109_29"/>line feeds are processed,
a "white-space-collapse" property that controls
how multiple consecutive spaces are collapsed,
and a "wrap-option" property
that controls whether lines are automatically wrapped when
they encounter a boundary, such as the edge of a column.
The effect of splitting a property into two or more
(sub-)properties is to make the equivalent existing CSS2
property a "shorthand" for the set of sub-properties it subsumes.
</p><p>
In still other cases, it was necessary to create new properties.
For example, there are a number of new properties that control how
hyphenation is done. These include identifying the script and country
the text is from as well as such properties as "hyphenation-character"
(which varies from script to script).
</p><p>
Some of the formatting objects and many of the properties in XSL
come from the CSS2 specification, ensuring compatibility
between the two.</p>
<p>
There are four classes of XSL properties that can be identified as:</p>
<olist><item><p>
CSS properties by copy (unchanged from their CSS2
semantics)</p></item>
<item><p>
CSS properties with extended values</p></item>
<item><p>
CSS properties broken apart and/or extended</p></item>
<item><p>
<spot id="c11i15"/>XSL-only properties</p></item></olist>
</div3>
<div3><head>Selectors and Tree Construction</head>
<p>
As mentioned above, XSL uses XSLT and XPath for tree construction
and pattern selection, thus providing a high degree of control
over how portions of the source content are presented, and what
properties are associated with those content portions, even where
mixed namespaces are involved.
</p><p>
For example, the patterns of XPath allow the selection of a portion
of a string or the Nth text node in a paragraph. This allows
users to have a rule that makes all third paragraphs in
procedural steps appear in bold, for instance. In addition,
properties can be associated with a content portion based on the
numeric value of that content portion or attributes on the
containing element. This allows one to have a style rule
that makes negative values appear in "red" and positive
values appear in "black". Also, text can be generated
depending on a particular context in the source tree,
or portions of the source tree may be presented
multiple times with different styles.
</p></div3>
<div3><head>An Extended Page Layout Model</head>
<p>
There is a set of formatting objects in XSL to describe both the
layout structure of a page or "frame"
(how big is the body; are there multiple columns;
are there headers, footers, or <spot id="c11i14_b"/>sidebars; how big are these)
and the rules by which the XML source content is placed into these "containers".
</p><p>
The layout structure is defined in terms of one or more instances
of a "simple-page-master" formatting object. This formatting
object allows one to define independently filled regions for
the body (with multiple columns), a header, a footer, and <spot id="c11i14_c"/>sidebars
on a page. These simple-page-masters can be used in page sequences
that specify in which order the various simple-page-masters shall be used.
The page sequence also specifies how styled content is to fill those pages.
This model allows one to specify a sequence of simple-page-masters
for a book chapter where the page instances are automatically
generated by the formatter or an explicit sequence of pages
such as used in a magazine layout. Styled content is assigned
to the various regions on a page by associating the name of the
region with names attached to styled content in the result tree.
</p><p>
In addition to these layout formatting objects and properties,
there are properties designed to provide the level of control
over formatting that is typical of paginated documents.
This includes control over hyphenation, and expanding the control over
text that is kept with other text in the same line, column,
or on the same page.
</p></div3>
<div3><head>A Comprehensive Area Model</head>
<p>
The extension of the properties and formatting objects,
particularly in the area on control over the spacing of blocks, lines,
and page regions and within lines, necessitated an extension of the
CSS2 box formatting model. This extended model is described
in <specref ref="area_model"/> of this
specification. The CSS2 box model is a
subset of this model.  See the mapping of the CSS2 box model
terminology to the XSL Area Model terminology in
<specref ref="cssbox"/>.
The area model provides a vocabulary for describing
the relationships and space-adjustment between
letters, words, lines, and blocks.</p>
</div3>
<div3><head>Internationalization and Writing-Modes</head>
<p>
There are <spot id="i18n_2"/>some scripts, in particular in the Far East, that are
typically set with words proceeding from top-to-bottom and
lines proceeding either from right-to-left (most common) or
from left-to-right. Other directions are also
used. Properties expressed in terms of a fixed,
absolute frame of reference (using top, bottom, left, and right)
and which apply only to a notion of words proceeding from left to right
or right to left do not generalize well to
<spot id="i18n_4"/>text written in those scripts.
</p><p>
For this reason XSL (and before it DSSSL) uses a relative frame of
reference for the formatting object and property descriptions. Just as
the CSS2 frame of reference has four directions (top, bottom, left and right),
so does the XSL relative frame of reference have four directions
(before, after, start, and end), but these are relative to the "writing-mode". The
"writing-mode" property is a way of controlling the
directions needed by a formatter to correctly place
glyphs, words, lines, blocks, etc. on the page or screen.
The "writing-mode" expresses the basic directions noted
above. There are writing-modes for "left-to-right - top-to-bottom"
(denoted as "lr-tb"), "right-to-left - top-to-bottom" (denoted as "rl-tb"),
"top-to-bottom - right-to-left" (denoted as "tb-rl") and more. <spot id="c11i16"/>See <specref ref="writing-mode"/>
for the description of the "writing-mode" property.
Typically, the writing-mode value specifies two directions:<spot id="c11i17"/>
the first is the inline-progression-direction which determines
the direction in which words will
be placed and the second is the block-progression-direction
which determines the direction in which blocks (and lines)
are placed one after another.
<spot id="i18n_5"/>In addition, the inline-progression-direction
for a sequence of characters may be implicitly determined using
bidirectional character types for those characters from the
Unicode Character Database  <bibref ref="UNICODE-CD"/>
for those characters and the Unicode <spot id="jm010109_11b"/>bidirectional (BIDI) algorithm <bibref ref="UNICODE-TR9"/>.
</p>
<p>
Besides the directions that are explicit in the name of the
value of the "writing-mode" property, the writing-mode determines
other directions needed by the formatter, such as the
shift-direction (used for <spot id="jm010109_30a"/>subscripts and superscripts), etc.
</p></div3>
<div3><head>Linking</head>
<p>
Because XML, unlike HTML, has no built-in semantics,
there is no built-in notion of a hypertext link.
<spot id="link01_i3"/>In this context, "link" refers
to "hypertext link" as defined in
<xspecref href="http://www.w3.org/TR/html401/struct/links.html#h-12.1" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/html401/struct/links.html#h-12.1</xspecref>
as well as some of the aspects of "link" as defined in
<xspecref href="http://www.w3.org/TR/xlink/#intro" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">http://www.w3.org/TR/xlink/#intro</xspecref>,
where "link is a relationship between two or more resources or
portions of resources, made explicit by an XLink linking element".
Therefore,
XSL has a formatting object that expresses the dual semantics of
formatting the content of the link reference and the
semantics of following the link.</p>
<p>
XSL provides a few mechanisms for changing the presentation
of a link target that is being visited. One of these mechanisms
permits indicating the link target as such;
another allows for control over the placement of the link
target in the viewing area; still another permits some degree of
control over the way the link target is displayed in relationship
to the originating link anchor.</p>
<p>XSL also provides a general mechanism for changing the way elements
are formatted depending on their active state. This is particularly
useful in relation to links, to indicate whether a given link
reference has already been visited, or to apply a given style
depending on whether the mouse, for instance, is hovering over
the link reference or not.</p>
</div3>
</div2>
</div1>


<div1><head><spot id="jm010109_2"/>XSL Transformation</head>
<div2>
<head>Tree Construction</head>
<p>The Tree Construction is described in
"XSL Transformations" <bibref ref="XSLT"/>.</p>
<p>The provisions in "XSL Transformations" form an integral part of
this <spot id="jm010109_10a"/>Recommendation and are considered normative.</p>
</div2>

<div2 id="xsl-namespace">
<head>XSL Namespace</head>

<p>The XSL namespace has the URI <code>http://www.w3.org/1999/XSL/Format</code>.</p>
<note><p>The <code>1999</code> in the URI indicates the year in which
the URI was allocated by the W3C.  It does not indicate the version of
XSL being used.</p></note>
<p>XSL processors must use the XML namespaces mechanism <bibref ref="XMLNAMES"/> to recognize elements and attributes from this
namespace. Elements from the XSL namespace are recognized only in the
stylesheet, not in the source document.
Implementors must not extend the XSL
namespace with additional elements or attributes. Instead, any
extension must be in a separate namespace.</p>
<p>This specification uses the prefix <code>fo:</code> for referring
to elements in the XSL namespace. However, XSL stylesheets are free
to use any prefix, provided that there is a namespace declaration that
binds the prefix to the URI of the XSL namespace.</p>
<p>An element from the XSL namespace may have any attribute not from
the XSL namespace, provided that the <xtermref href="http://www.w3.org/TR/xpath#dt-expanded-name" show="new" actuate="user" xmlns:xlink="http://www.w3.org/TR/WD-xlink">expanded-name</xtermref> of the
attribute has a non-null namespace URI.  The presence of such
attributes must not change the behavior of XSL elements and functions
defined in this document. Thus, an XSL processor is always free to
ignore such attributes, and must ignore such attributes without giving
an error if it does not recognize the namespace URI. Such attributes
can provide, for example, unique identifiers, optimization hints, or
documentation.</p>
<p>It is an error for an element from the XSL namespace to have
attributes with expanded-names that have null namespace URIs
(i.e., attributes with unprefixed names) other than
attributes defined for the element in this document.</p>
<note><p>The conventions used for the names of XSL elements,
attributes, and functions are as follows:
names are all <spot id="c11i18"/>lowercase,
hyphens are used to separate words, dots are used to
separate names for the components of complex datatypes,
and abbreviations are used only if they already
appear in the syntax of a related language such as XML or
HTML.</p></note>

</div2>

</div1>


<div1 id="fo-jc-intro"><head>Introduction to Formatting</head>
<p>The aim of this section is to describe the general process
of formatting, enough to read the area model and the
formatting object descriptions and properties and to
understand the process of refinement.</p>
<p><emph>Formatting</emph> is the process of turning the result of an XSL
transformation into a tangible form for the reader or listener. This
process comprises several steps, some of which depend on others in a
non-sequential way.
Our model for formatting will be the construction of an
<term>area tree</term>, which is an ordered tree containing
geometric information
for the placement of every glyph, shape, and image in the document,
together with information embodying spacing constraints and other rendering
information; this information is referred to under the rubric of
<emph>traits</emph>, which are to areas what properties are to formatting objects
and attributes are to XML <spot id="aj000035_4"/>elements.
<specref ref="area_model"/> will
describe the area tree and
define the default placement-constraints on stacked areas. However, this is
an abstract model which need not be actually implemented in this way
in a formatter, so long as the resulting tangible form obeys the implied constraints.
Constraints might conflict to the point where it is
impossible to satisfy them all.  In that case, it is
implementation-defined which constraints should be relaxed
and in what order to satisfy the others.
</p>
<p><emph>Formatting objects</emph> are elements in the formatting object tree, whose
names are from the XSL namespace; a formatting object belongs to a
<emph>class</emph> of formatting objects identified by its element name. The
formatting behavior of each class of formatting objects is described in
terms of what areas are created by a formatting object of that class, how
the traits of the areas are established, and how the areas are
structured hierarchically with respect to areas created by other formatting
objects. <specref ref="fo-section"/> and
<specref ref="pr-section"/><spot id="aj000029_19a"/>
describe formatting objects and their properties.</p>
<p>Some formatting objects are <emph>block-level</emph> and others are
<emph>inline-level</emph>. This refers to the types of areas which they generate,
which in turn refer to their default placement method. Inline-areas (for
example, glyph-areas) are collected into lines and the direction in which
they are stacked is the inline-progression-direction. Lines are a type of
block-area and these are stacked in a direction perpendicular to the
inline-progression-direction, called the block-progression-direction. See
<spot id="c11i1_a"/><specref ref="area_model"/> for detailed decriptions
of these area types and directions.</p>
<p>In Western writing systems, the block-progression-direction is
"top-to-bottom" and the inline-progression-direction is
"left-to-right". This specification treats other writing systems
as well and introduces the terms "block" and "inline"
instead of using absolute indicators like "vertical" and
"horizontal". Similarly this specification tries to give
relatively-specified directions ("before" and "after"
in the block-progression-direction, "start" and "end"
in the inline-progression-direction) where appropriate, either in addition
to or in place of absolutely-specified directions such as "top",
"bottom", "left", and "right". These are
interpreted according to the value of the writing-mode property.</p>
<p>Central to this model of formatting is <emph>refinement</emph>.
This is a computational
process which finalizes the specification of properties based on the attribute
values in the XML result tree. Though the XML result tree and the formatting object
tree have very similar structure, it is helpful to think of them as
separate conceptual entities. Refinement involves</p>
<ulist><item><p>propagating the various inherited values
of properties (both implicitly and those with an attribute value of "inherit"),
</p></item>
<item><p>evaluating expressions in property value specifications into actual
values, which
are then used to determine the value of the properties,<spot id="c11i20_a"/></p></item>
<item><p>converting relative numerics to absolute numerics,</p></item>
<item><p>constructing some composite properties from more than one attribute<spot id="c11i20_b"/></p></item>
</ulist>
<p>Some of these operations (particularly evaluating expressions) depend on knowledge
of the area tree. Thus refinement is not necessarily a straightforward, sequential
procedure, but may involve look-ahead, back-tracking, or control-splicing with
other processes in the formatter. Refinement is described more fully in
<spot id="c11i1_b"/><specref ref="refinement"/>.</p>
<p>To summarize, formatting proceeds by constructing an area tree
(containing areas and their traits) which satisfies constraints based on
information contained in the XML result tree (containing
element nodes and their
attributes). Conceptually, there are intermediate steps of
constructing a formatting object tree (containing formatting objects and their
properties) and refinement;
these steps may proceed in an interleaved fashion during the
construction of the area tree.</p>
<div2><head>Conceptual Procedure</head>
<p>This subsection contains a conceptual description of how
formatting could work. This conceptual
procedure does not mandate any particular algorithms or data structures as
long as the result obeys the implied constraints.</p>
<p>The procedure works by processing formatting objects. Each object,
while being processed, may initiate processing in other objects. While the
objects are hierarchically structured, the processing is not; processing of
a given object is rather like a co-routine which may pass control to other
processes, but pick up again later where it left off. The procedure starts
by initiating the processing of the fo:root
formatting object.</p>
<p>Unless otherwise specified, processing a formatting object creates areas
and returns
them to its parent to be placed in the area tree. Like a co-routine, it
resumes control later and initiates formatting of its own children (if
any), or some subset of them. The formatting object supplies parameters to its
children
based on the traits of areas already in the area tree, possibly including
areas generated by the formatting object or its ancestors. It then disposes of the
areas
returned by its formatting object children. It might simply
return such an area to its
parent (and will always do this if it does not generate areas itself), or
alternatively it might arrange the area in the area tree according to the
semantics of the formatting object; this may involve changing its geometric position.
It
terminates processing when all its children have terminated processing (if
initiated) and it is finished generating areas.</p>
<p>Some formatting objects do not themselves generate areas;<spot id="c11i21"/> instead these
formatting objects simply
return the areas returned to them by their children. Alternatively, a formatting object
may continue to generate (and return) areas based on information discovered
while formatting its own children; for example, the fo:page-sequence formatting object
will continue generating pages as long as it contains a flow with
unprocessed descendants.</p>
<p>Areas returned to an fo:root formatting object are
page-viewport-areas, and are simply placed as
children of the area tree root in the order in which they are returned,
with no geometrical implications.</p>
<p>As a general rule, the order of the area tree parallels the order of the
formatting object tree. That is, if one formatting object
precedes another in the depth-first
traversal of the formatting object tree, with neither
containing the other, then
all the areas generated by the first will precede all the areas generated
by the second in the depth-first traversal of the area tree, unless
otherwise specified. Typical exceptions to this rule would be things like
side floats, before floats, and footnotes.</p>
<p>At the end of the procedure, the areas and their traits have been
constructed, and they are required to satisfy constraints described in the
definitions of their associated formatting objects, and in the area model
section. In particular, size and position of the areas will be subject to
the placement and spacing constraints described in the area model, unless
the formatting object definition indicates otherwise.</p>
<p>The formatting object definitions, property descriptions, and area model
are not algorithms. Thus, the formatting object semantics do not specify how
the line-breaking algorithm must work in collecting characters into words,
positioning words within lines, shifting lines within a container, etc.
Rather this specification assumes that the formatter has done these things
and describes the constraints which the result is supposed to
satisfy.</p>
</div2>
</div1>




<div1 id="area_model"><head>Area Model</head>
<p>In XSL, one creates a tree of formatting objects that serve as inputs or
specifications to a formatter. The formatter generates a hierarchical arrangement
of areas which comprise the formatted result. This section defines the general
model of areas and how they interact. The purpose is to present an abstract
framework which is used in describing the semantics of formatting objects.
It should be seen as describing a series of constraints for
conforming implementations,
and not as prescribing particular algorithms.</p>
<div2 id="area-intro"><head>Introduction</head>
<p>The formatter generates an ordered tree, the <term>area tree,</term> which
describes a geometric structuring of the output medium. The terms
<term>child, sibling, parent, descendant,</term> and <term>ancestor</term>
refer to this tree structure. The tree has a <term>root node</term>.</p>
<p>Each area tree node other than the root is called an <term>area</term> and is
associated to a rectangular portion of the output medium. Areas are
not formatting objects; rather, a formatting object generates zero or more
rectangular areas, and normally each area is generated by a unique object in the
formatting object tree.</p>
<note><p>The only exceptions are when several leaf nodes of the formatting object
tree are combined
to generate a single area, for example when several characters
in sequence generate a single ligature
glyph. In all such cases, relevant properties such as
<trait>font-family</trait> and <trait>font-size</trait> are the same for
all the generating formatting objects (see section <specref ref="area-linebuild"/>).</p></note>
<p>An area has a <term>content-rectangle</term>,
the portion in which its child areas are assigned, and optional
<term>padding</term> and <term>border</term>. The diagram shows
how these portions are related to one another. The outer bound of the border
is called the <term>border-rectangle</term>, and the outer
bound of the
padding is called the <term>padding-rectangle</term>.</p>
<graphic source="RectsOnlyForModel.gif" alt="Elements of an area" longdesc="Nested rectangles showing the components of an area: innermost is the content rectangle, nested within the padding rectangle, itself nested within the border rectangle." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<p>Each area has a set of <term>traits</term>, a mapping of names to values,
in the way elements have attributes and formatting objects have properties.
Individual traits are used either
for rendering the area or for defining constraints on the result of formatting,
or both. Traits used strictly for formatting purposes or for defining
constraints may be called <term>formatting traits</term>, and traits used for
rendering may be called <term>rendering traits</term>.
Traits whose values are copied or derived from <spot id="aj000029_22a"/>a property
of the same or a corresponding
name are listed in <specref ref="property-index"/> and <specref ref="refinement"/>;
other traits are listed below.</p>
<note><p>Traits are also associated with FOs during the process of refinement.
Some traits are assigned during formatting, while others are already present after
refinement.</p></note>
<p>The semantics of each type of formatting object that generates areas are
given in terms of which areas it generates and their place in the area-tree
hierarchy. This may be further modified by interactions between the various
types of formatting
objects. The properties of the formatting object determine what areas are
generated and how the formatting object's content is distributed among them.
(For example, a word that is not to be hyphenated may not have its glyphs
distributed into areas on two separate line-areas.)</p>
<p>The traits of an area are either:</p>
<p><term>directly-derived</term>: the values of directly-derived traits are the computed
value of a property of the same or a corresponding name on the generating formatting object, or</p>
<p><term>indirectly-derived</term>: the values of indirectly-derived traits are the
result of a computation involving the computed values of one or more properties
on the generating formatting object, other traits on this area or other
interacting areas (ancestors, parent, siblings, and/or children) and/or
one or more values constructed by the formatter. The calculation formula
may depend on the type of the formatting object.</p>
<p>This description assumes that refined values have been computed for all
properties of formatting objects in the result tree, i.e.,
all relative and corresponding values have been computed and the inheritable
values have been propagated as described in <specref ref="refinement"/>. This
allows the
process of inheritance to be described once and avoids a need to repeat
information on computing values
in this description.</p>
<p>The indirectly-derived traits are:
<trait>block-progression-direction</trait>,
<trait>inline-progression-direction</trait>,
<trait>shift-direction</trait>,
<trait>glyph-orientation</trait>,
<trait>is-reference-area</trait>,
<trait>is-viewport-area</trait>,
<trait>left-position</trait>,
<trait>right-position</trait>,
<trait>top-position</trait>,
<trait>bottom-position</trait>,
<trait>left-offset</trait>,
<trait>top-offset</trait>,
<trait>is-first</trait>,
<trait>is-last</trait>,
<trait>alignment-point</trait>,
<trait>area-class</trait>,
<trait>start-intrusion-adjustment</trait>,
<trait>end-intrusion-adjustment</trait>,
<trait>generated-by</trait>,
<trait>returned-by</trait>,
<trait>page-number</trait>,
<trait>blink</trait>,
<trait>underline-score</trait>,
<trait>overline-score</trait>,
<trait>through-score</trait>,
<trait>underline-score-color</trait>,
<trait>overline-score-color</trait>,
<trait>through-score-color</trait>,
<trait>alignment-baseline</trait>,
<trait>baseline-shift</trait>,
<trait>nominal-font</trait>,
<trait>dominant-baseline-identifier</trait>,
<trait>actual-baseline-table</trait>, and
<trait>script</trait>.
</p>
</div2>
<div2 id="area-rect"><head>Rectangular Areas</head>
<div3><head>Area Types</head>
<p>There are two types of areas: <term>block-areas</term> and
<term>inline-areas</term>. These differ according to how
they are typically stacked by the formatter. An area can have
block-area children or inline-area children as determined
by the generating formatting object, but a given area's children must all be of
one type. Although block-areas and inline-areas are
typically stacked, some areas can be explicitly positioned.</p>
<p>A <term>line-area</term> is a special kind of block-area whose children
are all inline-areas. A <term>glyph-area</term> is a special kind of
inline-area which has no child areas, and has a single
glyph image as its content.</p>
<p>Typical examples of areas are: a paragraph rendered by using
an fo:block formatting object,
which generates block-areas,
and a character rendered by using an fo:character
formatting object,
which generates an inline-area (in fact, a glyph-area).</p>
</div3>
<div3 id="area-common"><head>Common Traits</head>
<p>Associated with any area are two directions, which are derived from the
generating
formatting object's <trait>writing-mode</trait> and
<trait>reference-orientation</trait> properties: the
<term>block-progression-direction</term> is the direction for stacking block-area
descendants of the area, and the
<term>inline-progression-direction</term> is the direction for stacking inline-area
descendants of the area. Another
trait, the <term>shift-direction</term>, is present on inline-areas and refers to
the direction in which baseline
shifts are applied. Also the <term>glyph-orientation</term> defines the orientation
of glyph-images in the rendered result.</p>

<p>If the reference-orientation for an area is 0, then the
top, bottom, left, and right edges of the content are parallel to those of
the area's parent and consistent with them. Otherwise the edges are rotated
from those of the area's parent as described in <specref ref="reference-orientation"/>.
The inline-progression-direction and block-progression-direction are determined
by the location of these edges as described in <specref ref="writing-mode"/>.</p>

<p>The Boolean trait <trait>is-reference-area</trait> determines
whether or not an area establishes a coordinate system for
specifying indents. An area for which this trait is <code role="value">true</code>
is called a <term>reference-area</term>.
Only a reference-area may have a block-progression-direction which is different from
that of its parent.
A reference-area may be either a
block-area or an inline-area.</p>

<p>The Boolean trait <trait>is-viewport-area</trait> determines
whether or not an area establishes an opening through which its
descendant areas can be viewed, and can be used to
present clipped or scrolled material; for example, in printing
applications where bleed and trim is desired.
An area for which this trait is <code role="value">true</code>
is called a <term>viewport-area</term>.
</p>
<p>A common construct is a <term>viewport/reference pair</term>.
This is a <spot id="jc-20010515-remove-block"/>
viewport-area <var>V</var> and a block-area
reference-area <var>R</var>, where <var>R</var> is the sole child
of <var>V</var> and where the start-edge and end-edge of the
content-rectangle of <var>R</var> are parallel to the start-edge and
end-edge of the content-rectangle of <var>V</var>.</p>

<p>Each area has the traits <term>top-position</term>, <term>bottom-position</term>,
<term>left-position</term>, and <term>right-position</term> which represent the distance
from the edges of its content-rectangle to the like-named edges of the
nearest ancestor reference-area (or the page-viewport-area
in the
case of areas generated by descendants of formatting objects
whose absolute-position is <code role="value">fixed</code>); the <term>left-offset</term>
and <term>top-offset</term> determine the amount by which
a relatively-positioned area is shifted for rendering.  These traits receive
their values during the formatting process, or in the case
of absolutely positioned areas, during refinement.</p>
<p>The <term>block-progression-dimension</term> and
<term>inline-progression-dimension</term> of an area represent the
extent of the content-rectangle of that area in each of the two
relative <spot id="aj000029_23a"/>dimensions.</p>

<p>Other traits include:</p>
<ulist><item>
<p>the <trait>is-first</trait> and <trait>is-last</trait> traits, which are Boolean traits
indicating the order in which areas are generated and returned by a given
formatting object.
<spot id="jc-20010515-returned-order"/>(See <specref ref="define-returned-by"/>.
<trait>is-first</trait> is <code role="value">true</code>
for the first area (or only area) generated and returned by a formatting object,
and <trait>is-last</trait>
is <code role="value">true</code> for the last area (or only area));</p></item>
<item>
<p>the amount of space outside the border-rectangle: <term>space-before</term>,
<term>space-after</term>, <term>space-start</term>, and <term>space-end</term>
(though some of these may be required to be zero on certain classes of area);</p>
<note><p>"Before", "after", "start",
and "end" refer to relative directions and are defined
below.</p></note>
</item>
<item><p>the thickness of each of the four sides of the padding: <term>padding-before</term>,
<term>padding-after</term>, <term>padding-start</term>, and <term>padding-end</term>;</p></item>
<item><p>the style, thickness, and color of each of the
four sides of the border: <term>border-before</term>, etc.;</p></item>
<item><p>the background rendering of the
area: <term>background-color</term>, <term>background-image</term>, and
other background traits; and</p>
</item><item>
<p>the <trait>nominal-font</trait> for an area, as
determined by the font properties and the character descendants of the
area's generating formatting object.
(see <specref ref="fontprops"/>)<spot id="jm010109_31"/></p></item>
</ulist>
<p>Unless otherwise specified, the traits of a
formatting object are present on each of its generated areas,
and with the same value. (However, see sections
<specref ref="area-linebuild"/> and <specref ref="rend-border"/>.)</p>
</div3>
<div3 id="area-geo"><head>Geometric Definitions</head>
<p>As described above, the <term>content-rectangle</term> is the rectangle
bounding the inside of the padding and is used to describe
the constraints on the positions of descendant areas. It is possible that
marks from descendant glyphs or other areas may appear outside the
content-rectangle.</p>
<p>Related to this is the <term>allocation-rectangle</term>
of an area,
which is used to describe the constraints on the position of
the area within its parent area. For an inline-area this is either the
<term>normal-allocation-rectangle</term> or the <term>large-allocation-rectangle</term>.
The <term>normal-allocation-rectangle</term>
extends
to the content-rectangle
in the block-progression-direction and to the border-rectangle in the
inline-progression-direction. The <term>large-allocation-rectangle</term>
is the border-rectangle. Unless
otherwise specified, the allocation-rectangle for an area is the
normal-allocation-rectangle.
</p>
<figure>
<graphic source="AllocationRectInline.4.gif" alt="Normal-allocation-rectangle of an inline-area" longdesc="This diagram shows the position of the normal allocation rectangle of an inline area, as described in the text." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Normal-allocation-rectangle of an inline-area</p></figcap>
</figure>
<figure>
<graphic source="AllocationRectInline-Large.gif" alt="Large-allocation-rectangle of an inline-area" longdesc="This diagram shows the position of the large allocation rectangle of an inline area, which is the same at the border rectangle." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p><spot id="jm010063_1"/>Large-allocation-rectangle of an inline-area</p></figcap>
</figure>
<p>For a block-area, the allocation-rectangle extends to the border-rectangle in
the block-progression-direction and outside the content-rectangle
in the inline-progression-direction by an amount equal to
the <trait>end-indent</trait>,
and in the opposite direction by an amount equal to the <trait>start-indent</trait>.</p>
<note><p>The inclusion of space outside the border-rectangle of a block-area
in the inline-progression-direction does not affect
placement constraints, and
is intended to promote compatibility with the CSS box model.</p></note>
<figure>
<graphic source="AllocationRect.2.gif" alt="Allocation- and content-rectangles of a block-area" longdesc="This diagram shows the position of the allocation rectangle of a block area, as described in the text." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Allocation- and content-rectangles of a block-area</p></figcap>
</figure>
<p>The edges of a rectangle are designated as follows:</p>
<ulist><item>
<p>the <term>before-edge</term> is the edge occurring first in the
block-progression-direction and perpendicular
to it;</p></item>
<item><p>the <term>after-edge</term> is the edge opposite
the before-edge;</p></item>
<item><p>the <term>start-edge</term> is the edge occurring
first in the inline-progression-direction and perpendicular
to it,</p></item>
<item><p>the <term>end-edge</term> is the edge opposite the
start-edge.</p></item></ulist>
<p>For purposes of this definition, the content-rectangle of an area uses the
inline-progression-direction and block-progression-direction of that area;
but the border-rectangle, padding-rectangle, and
allocation-rectangle use the
directions of its parent area. <spot id="edges_may_not_correspond"/>Thus the edges designated for the
content-rectangle may not correspond to the same-named edges
on the padding-, border-,
and allocation-rectangles. This is important in the case of
nested block-areas with different writing-modes.</p>
<p>The following diagram shows the correspondence between the various edge
names for a mixed writing-mode example:</p>
<graphic source="japaneseblock3.gif" alt="Embedded areas with different writing-modes" longdesc="Example of nested areas with different writing modes: a block with English text (writing mode: left-to-right, top-to-bottom) contains a block with Japanese text (writing-mode: top-to-bottom, right-to-left). The position of relative edges (start, end, before and after) is shown on each area." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>

<p>Each inline-area has an <term>alignment-point</term> determined by the formatter,
on the start-edge
of its allocation-rectangle; for a glyph-area, this is
a point on the start-edge of the glyph on its alignment baseline (see below).
This is script-dependent and does not necessarily correspond to the
(0,0) coordinate point used for the data describing the glyph shape.</p>
</div3>
<div3 id="area-treeorder"><head>Tree Ordering</head>
<p>In the area tree, the set of areas with a given parent is ordered.
The terms <term>initial, final, preceding</term>, and
<term>following</term> refer to this ordering.</p>

<p>In any ordered tree, this sibling order extends to an ordering of the entire tree
in at least two ways.</p>
<ulist><item><p>In the <term>pre-order traversal order</term> of a tree, the children
of each node (their order unchanged relative to one another) follow the node, but
precede any following siblings of the node or of its ancestors.</p></item>
<item><p>In the <term>post-order traversal order</term> of a tree, the children of
each node precede the node, but follow any preceding siblings of the node or of its
ancestors.</p></item></ulist>
<p>"Preceding" and "following", when applied to non-siblings, will depend on the
extension order used, which must be specified. However, in either of these given orders,
the leaves of the tree (nodes without children) are unambiguously ordered.</p>
</div3>

<div3 id="area-stackcon"><head>Stacking Constraints</head>
<p>This section defines the notion of <term>block-stacking constraints</term> and
<term>inline-stacking constraints</term> involving areas. These are defined as
ordered relations, i.e., if <var>A</var> and <var>B</var>
have a stacking constraint
it does not necessarily mean that <var>B</var> and <var>A</var> have a stacking
constraint. These definitions are recursive in nature and some cases may depend
upon simpler cases of the same definition. This is not circularity but rather a
consequence of recursion. The intention of the
definitions is to identify areas at any level of the
tree which have only space between them.</p>
<p>The <trait>area-class</trait> trait is an enumerated value which is
<code role="value">xsl-normal</code> for an area which is stacked with
other areas in sequence.  A <term>normal</term> area is an
area for which this trait is <code role="value">xsl-normal</code>. A
<term>page-level-out-of-line</term>
area is an area with area-class <code role="value">xsl-footnote</code>,
<code role="value">xsl-before-float</code>,
or <code role="value">xsl-fixed</code>; placement of these areas is controlled
by the fo:page-sequence
ancestor of its generating formatting object.  A <term>reference-level-out-of-line</term>
area is an area with area-class
<code role="value">xsl-side-float</code> or <code role="value">xsl-absolute</code>;
placement of these areas is controlled by the formatting object generating
the relevant reference-area.   An <term>anchor</term>
area is an area with area-class
<code role="value">xsl-anchor</code>;
placement of these areas is arbitrary and does not affect stacking.
Areas with area-class equal to one of
<code role="value">xsl-normal</code>,
<code role="value">xsl-footnote</code>, or
<code role="value">xsl-before-float</code> are defined to be
<term>stackable</term>,
indicating that they are supposed to be properly stacked.
</p>
<p><emph>Block-stacking constraints</emph></p>
<p>If <var>P</var> is a block-area, then there is a <term>fence preceding</term>
<var>P</var> if <var>P</var> is a reference-area or if the
border-before-width
or padding-before-width of <var>P</var> are non-zero.
Similarly, there is a
<term>fence following</term> <var>P</var> if <var>P</var> is a
reference-area
or if the border-after-width or padding-after-width of <var>P</var> are non-zero.</p>
<p>If <var>A</var> and <var>B</var> are stackable areas, and <var>S</var> is
a sequence of space-specifiers (see <specref ref="spacecond"/>),
it is defined that <term><var>A</var> and <var>B</var>
have block-stacking constraint <var>S</var></term> if
any of the following conditions holds:</p>
<olist>
<item><p><var>B</var> is a block-area which is the first normal
child of <var>A</var>, and <var>S</var> is the sequence consisting of the
space-before of <var>B</var>.</p></item>
<item><p><var>A</var> is a block-area which is the last normal
child of <var>B</var>, and <var>S</var> is the sequence consisting of the
space-after of <var>A</var>.</p></item>
<item><p><var>A</var> and <var>B</var> are both block-areas, and either</p>
    <p>a. <var>B</var> is the next stackable sibling area of <var>A</var>,
    and <var>S</var> is the sequence consisting of the space-after of <var>A</var>
    and the space-before of <var>B</var>;</p>

    <p>b. <var>B</var> is the first normal child of a block-area
    <spot id="jm010061"/><var>P</var>,
<var>B</var> is not a line-area,
    there is no fence preceding <var>P</var>,
<var>A</var> and
    <var>P</var> have a block-stacking constraint <var>S</var>', and <var>S</var>
    consists of <var>S</var>' followed by the space-before of <var>B</var>; or</p>
    <p>c. <var>A</var> is the last normal child of a block-area
    <var>P</var>,
<var>A</var> is not a line-area,
    there is no fence following <var>P</var>,
<var>P</var> and
    <var>B</var> have a block-stacking constraint <var>S</var>'', and <var>S</var>
    consists of the space-after of <var>A</var> followed by <var>S</var>''.</p>

   <p>d.
<spot id="jc-20010328-empties1"/>

<var>A</var> has a block-stacking constraint <var>S'</var> with a
    block-area <var>E</var>, <var>E</var> has a block-stacking constraint <var>S''</var>
    with <var>B</var>, <var>E</var> is
    <term>empty</term> (i.e., it has zero border,
    padding, and block-progression-dimension, and no normal children), and
    <var>S</var> consists of <var>S'</var> followed by
    <var>S''</var>.</p>

    </item>
</olist>
<note><p>The use of "stackable" in two places in the above definition allows
block-stacking constraints to apply between areas of area-class
<code role="value">xsl-before-float</code>
or <code role="value">xsl-footnote</code>.</p></note>
<figure>
<graphic source="block-stacking-constraints.gif" alt="Adjacent Edges with Block-stacking" longdesc="Five examples that illustrate each of the possible cases of block-stacking constraints listed above. In each case, the adjacent edge of the blocks is outlined." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Adjacent Edges with Block-stacking</p></figcap>
</figure>
<p>When <var>A</var> and <var>B</var> have a block-stacking constraint, the
<term>adjacent edges</term> of <var>A</var> and <var>B</var> are an ordered
pair recursively defined as:</p>
<ulist><item><p>In case 1, the before-edge of the
content-rectangle of <var>A</var>
and the before-edge of the allocation-rectangle of <var>B</var>.</p></item>

<item><p><spot id="jm010062_1-2"/>In case 2, the after-edge of the allocation-rectangle
of <var>A</var> and
the after-edge of the content-rectangle of <var>B</var>.</p></item>
<item><p>In case 3a, the after-edge of the
allocation-rectangle of <var>A</var>
and the before-edge of the allocation-rectangle of <var>B</var>.</p></item>
<item><p>In case 3b, the first of the adjacent edges of <var>A</var> and <var>P</var>,
and the before-edge of the allocation-rectangle of <var>B</var>.</p></item>
<item><p>In case 3c, the after-edge of the
allocation-rectangle of <var>A</var>
and the second of the adjacent edges of <var>P</var> and <var>B</var>.</p></item>

<item><p>In
<spot id="jc-20010328-empties2"/>

case 3d, the first of the adjacent edges of <var>A</var> and <var>E</var>,
and the second of the adjacent edges of <var>E</var> and <var>B</var>.</p></item>

</ulist>


<p><emph>Example</emph>. In this diagram each node represents a block-area.

Assume that all padding
and border widths are zero, and none of the areas are
reference-areas. Then <var>P</var>
and <var>A</var> have a block-stacking constraint, as do <var>A</var>
and <var>B</var>, <var>A</var> and

<var>C</var>, <var>B</var> and <var>C</var>, <var>C</var> and <var>D</var>,
<var>D</var> and <var>B</var>,
<var>B</var> and

<var>E</var>, <var>D</var> and

<var>E</var>, and <var>E</var> and

<var>P</var>; these

are the only pairs  in the diagram having block-stacking constraints. If

<var>B</var> had non-zero padding-after, then <var>D</var>

and <var>E</var> would not have any block-stacking constraint (though <var>B</var>

and <var>E</var> would continue to have a block-stacking constraint).</p>

<figure>
<graphic source="mantree.gif" alt="Block-stacking constraint example" longdesc="Diagram of the tree used as an example in the text. A root node P has three children: A, B and E. B has two childrem: C and D." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Block-stacking constraint example</p></figcap>
</figure>

<p><emph>Inline-stacking constraints.</emph></p>
<p>This section will recursively define the
inline-stacking constraints between two areas (either two inline-areas or one inline-area
and one line-area),
together with the notion of
<term>fence preceding</term> and <term>fence following</term>; these definitions are interwoven with one another.
This parallels the definition for block-stacking
constraints, but with the additional complication that we may have a stacking
constraint between inline-areas which are stacked in opposite inline-progression-directions.
(This is not an issue for block-stacking constraints because
a block-area which is not a reference-area may not have a
block-progression-direction
different from that of its parent.)</p>
<p>If <var>P</var> and <var>Q</var> have an inline-stacking constraint, then
<var>P</var> has a <term>fence preceding <var>Q</var></term> if <var>P</var> is
a reference-area or has non-zero border-width or padding-width at the first
adjacent edge of <var>P</var> and <var>Q</var>. Similarly, <var>Q</var> has
a <term>fence following <var>P</var></term> if <var>Q</var> is a reference-area
or has non-zero border-width or padding-width at the second
adjacent edge of
<var>P</var> and <var>Q</var>.</p>
<p>If <var>A</var> and <var>B</var> are normal areas, and <var>S</var>
is a sequence of space-specifiers, it is defined that <term><var>A</var> and
<var>B</var> have inline-stacking constraint <var>S</var></term> if any of the
following conditions holds:</p>
<olist>
<item><p><var>A</var> is an inline-area or line-area, <var>B</var> is an inline-area which is the first normal child of
<var>A</var>, and <var>S</var> is the sequence consisting of the space-start of
<var>B</var>.</p></item>
<item><p><var>B</var> is an inline-area or line-area, <var>A</var> is an inline-area which is the last normal child of
<var>B</var>, and <var>S</var> is the sequence consisting of the space-end of
<var>A</var>.</p></item>
<item><p><var>A</var> and <var>B</var> are each either an inline-area or a line-area, and either</p>
    <p>a. both <var>A</var> and <var>B</var> are inline-areas,
    <var>B</var> is the next normal sibling area of <var>A</var>,
    and <var>S</var> is the sequence consisting of the space-end of <var>A</var>
    and the space-start of <var>B</var>;</p>
    <p>b. <var>B</var> is an inline-area which is the first normal child of an inline-area <var>P</var>,
	      <var>P</var> has no fence following <var>A</var>,
<var>A</var> and <var>P</var> have an
		  inline-stacking constraint <var>S</var>', the inline-progression-direction of
		  <var>P</var> is the same as the inline-progression-direction of the nearest
		  common ancestor area of <var>A</var> and <var>P</var>, and <var>S</var> consists of
		  <var>S</var>' followed by the space-start of <var>B</var>.</p>
    <p>c. <var>A</var> is an inline-area which is the last normal child of an inline-area <var>P</var>,
	      <var>P</var> has no fence preceding <var>B</var>,
<var>P</var> and <var>B</var> have an
		  inline-stacking constraint <var>S</var>'', the inline-progression-direction of
		  <var>P</var> is the same as the inline-progression-direction of the nearest
		  common ancestor area of <var>P</var> and <var>B</var>, and <var>S</var> consists of the
		  space-end of <var>A</var> followed by <var>S</var>''.</p>
    <p>d. <var>B</var> is an inline-area which is the last normal child of an inline-area <var>P</var>,
	      <var>P</var> has no fence following <var>A</var>,
<var>A</var> and <var>P</var> have an
		  inline-stacking constraint <var>S</var>', the inline-progression-direction of
		  <var>P</var> is opposite to the inline-progression-direction of the nearest
		  common ancestor area of <var>A</var> and <var>P</var>, and <var>S</var> consists of
		  <var>S</var>' followed by the space-end of <var>B</var>.</p>
    <p>e. <var>A</var> is an inline-area which is the first normal child of an inline-area <var>P</var>,
	      <var>P</var> has no fence preceding <var>B</var>,
<var>P</var> and <var>B</var> have an
		  inline-stacking constraint <var>S</var>'', the inline-progression-direction of
		  <var>P</var> is opposite to the inline-progression-direction of the nearest
		  common ancestor area of <var>P</var> and <var>B</var>, and <var>S</var> consists of the
		  space-start of <var>A</var> followed by <var>S</var>''.</p>
</item>
</olist>
<figure>
<graphic source="inline-stacking1.gif" alt="Adjacent Edges with Inline-stacking" longdesc="Two examples of inline-stacking constraints, illustrating cases 1 and 2 above. The first shows an inline area A containing another area B (A's first child). The left edges of both A and B are outlined. In the second, B contains A, as its last child, and both right edges are outlined." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Adjacent Edges with Inline-stacking</p></figcap>
</figure>
<figure>
<graphic source="inline-stacking2.gif" alt="Adjacent Edges with Inline-stacking, continued" longdesc="Three examples of inline-stacking constraints. The first (case 3a) shows two glyph areas A (left) and B (right) next to each other. The right edge of A and the left edge of B are outlined. The second case (3b) shows four adjacent glyph areas (containing an English word and a space A), followed by another inline area containing Devanagari glyphs. The right edge of the space glyph and the left edge of the leftmost Devanagari glyph are outlined. The third case (3c) shows an inline area P containing the word 'bold', to the left of an white space area B. The glyph 'd' is in a glyph area A. The right edge of A and the left edge of B are outlined. " xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Adjacent Edges with Inline-stacking, continued</p></figcap>
</figure>
<figure>
<graphic source="inline-stacking3.gif" alt="Adjacent Edges with Inline-stacking, continued" longdesc="This diagram illustrates case 3d. Four adjacent glyph areas (three Roman letters and a space A) followed by a inline area P containing Arabic glyph areas, the leftmost of which is labelled B. The right edge of A and the left edge of B are outlined. The diagram also shows a tree view of this structure. The root node has five children: the three Roman letters, the space and the Arabic word. The latter is itself a node containing each Arabic glyph, in document order, i.e. reversed from rendered order." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Mixed English and Arabic</p></figcap>
</figure>
<figure>
<graphic source="inline-stacking4.gif" alt="Adjacent Edges with Inline-stacking, continued" longdesc="Case 3e: an inline block P containin Arabic glyph areas is followed by a space glyph B and two other glyphs (Roman). The right edge of the rightmost arabic glyph A and the left edge of B are outlined. A tree view of this structure has a root node with 4 children: the Arabic wordm the space, and the two Roman glyphs. The arabic word is itself a node whose children are glyphs in reverse order than the corresponding areas." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Mixed English and Arabic</p></figcap>
</figure>

<p><spot id="fo0001sca_a"/>When <var>A</var> and <var>B</var> have an inline-stacking constraint,
the <term>adjacent edges</term> of <var>A</var> and <var>B</var> are an ordered
pair defined as:</p>
<ulist><item><p>In case 1, the start-edge of the
content-rectangle of <var>A</var>
and the start-edge of the allocation-rectangle of <var>B</var>.</p></item>

<item><p><spot id="jm010062_1-1"/>In case 2, the end-edge of the allocation-rectangle of <var>A</var> and
the end-edge of the content-rectangle of <var>B</var>.</p></item>
<item><p>In case 3a, the end-edge of the
allocation-rectangle of <var>A</var> and
the start-edge of the allocation-rectangle of <var>B</var>.</p></item>
<item><p>In case 3b, the first of the adjacent edges of <var>A</var> and
<var>P</var>, and the start-edge of the allocation-rectangle of <var>B</var>.</p></item>
<item><p>In case 3c, the end-edge of the
allocation-rectangle of <var>A</var>
and the second of the adjacent edges of <var>P</var> and <var>B</var>.</p></item>
<item><p>In case 3d, the first of the adjacent edges of <var>A</var> and
<var>P</var>, and the end-edge of the allocation-rectangle of <var>B</var>.</p></item>
<item><p>In case 3e, the start-edge of the
allocation-rectangle of <var>A</var>
and the second of the adjacent edges of <var>P</var> and <var>B</var>.</p></item></ulist>

<p>Two areas are <term>adjacent</term> if they have a block-stacking constraint
or an inline-stacking constraint. It follows from the definitions that areas of the same
type (inline or block) can be adjacent only if all their non-common ancestors
are also of the same type (up to but not including their nearest common ancestor).
Thus, for example, two inline-areas which reside in different line-areas are never
adjacent.</p>

<p>An area <var>A</var> <term>begins</term> an area <var>P</var> if <var>A</var> is a
descendant of <var>P</var> and <var>P</var> and <var>A</var> have either a
block-stacking constraint or an inline-stacking constraint. In this case the
second of the adjacent edges of <var>P</var> and <var>A</var> is defined to be
a <term>leading edge</term> in <var>P</var>. A space-specifier which applies to
the leading edge is also defined to <term>begin</term> <var>P</var>.</p>

<p>Similarly, An area <var>A</var> <term>ends</term> an area <var>P</var> if <var>A</var> is a
descendant of <var>P</var> and <var>A</var> and <var>P</var> have either a
block-stacking constraint or an inline-stacking constraint. In this case the
first of the adjacent edges of <var>A</var> and <var>P</var> is defined to be
a <term>trailing edge</term> in <var>P</var>. A space-specifier which applies to
the trailing edge is also defined to <term>end</term> <var>P</var>.</p>
</div3>
<div3 id="area-font"><head>Font Baseline Tables</head>
<p>Each script has its preferred "baseline" for aligning glyphs from that script.
Western scripts typically use an "alphabetic" baseline that touches at or near the
bottom of capital letters. Further, for each font there is a
preferred way of aligning embedded glyphs from different scripts, e.g., for a
Western font there are separate baselines for aligning embedded ideographic or Indic
glyphs.</p>
<p>Each block-area and inline-area has a
<trait>dominant-baseline-identifier</trait> trait whose value is a baseline identifier
corresponding to the type of alignment expected for inline-area descendants of that area,
and each inline-area has an <trait>alignment-baseline</trait> which specifies how the
area is aligned to its parent. These traits are interpreted as described in section
<specref ref="font-model"/>.</p>
<p>For each font, an <trait>actual-baseline-table</trait> maps these identifiers
to points on the start-edge of the area. <spot id="area-dominant-baseline-abuse"/>By
abuse of terminology, the line in the inline-progression-direction
through the point corresponding to the dominant-baseline-identifier is called
the "dominant baseline."</p>
</div3>
</div2>
<div2 id="spacecond"><head>Spaces and Conditionality</head>
<p>A space-specifier is a compound datatype whose components are minimum, optimum,
<spot id="aj000035_6a"/>maximum, conditionality, and precedence.</p>
<p><term>Minimum</term>, <term>optimum</term>, and <term>maximum</term> are lengths
and can be used to define a constraint
on a distance, namely that the distance should preferably be the optimum,
and in any case no less than the minimum nor more than the maximum. Any of these
values may be negative, which can (for
example) cause areas to overlap, but in any case the minimum should be less
than or equal to the optimum value, and the optimum less than or equal to
the maximum value.</p>
<p><term>Conditionality</term> is an enumerated value which controls whether a
space-specifier has effect at the beginning or end of a reference-area or a
line-area. Possible values are <code role="value">retain</code> and
<code role="value">discard</code>;
a <term>conditional</term> space-specifier is one for which this value is
<code role="value">discard</code>.</p>
<p><term>Precedence</term> has a value which is either an integer or the special
token <code role="value">force</code>. A <term>forcing</term> space-specifier
is one for which this value is <code role="value">force</code>.</p>
<p>Space-specifiers occurring in sequence may interact with each other. The
constraint imposed by a sequence of space-specifiers is computed by
calculating for each space-specifier
its associated <term>resolved space-specifier</term> in accordance with
their conditionality and precedence, as
shown below in the space-resolution rules.</p>
<p>The constraint imposed on a distance by a sequence of resolved space-specifiers
is additive; that is, the distance is constrained to be no less than the
sum of the resolved minimum values and no larger than the sum of the resolved
maximum values.</p>
<div3 id="area-space"><head>Space-resolution Rules</head>





<p><spot id="js010069"/>The
resolved space-specifier of a given space-specifier <var>S</var> is
computed as follows. Consider the maximal inline-stacking constraint or
block-stacking constraint <var>S''</var> containing the space-specifier
<var>S</var> as an element of the sequence (<var>S''</var> is a sequence
of space-specifiers; see <specref ref="area-stackcon"/>). Define
<var>S'</var> to be a subsequence of <var>S''</var> as follows:</p>
<ulist>
<item><p>if <var>S</var> is the space-before or space-after of a line-area,
then <var>S'</var> is the maximal subsequence of <var>S''</var> containing
<var>S</var> such that all the space-specifiers in <var>S'</var> are traits
of line-areas,</p></item>
<item><p>if <var>S</var> is the space-before or space-after of a block-area
which is not a line-area,  then <var>S'</var> is the maximal subsequence
of <var>S''</var> containing <var>S</var> such that all the space-specifiers
in <var>S'</var> are traits of block-areas which are not
line-areas,</p></item>
<item><p>if <var>S</var> is the space-start or space-end of an inline-area,
then <var>S'</var> is all of <var>S''</var>.</p></item>
</ulist>
<p>The resolved space-specifier of <var>S</var> is a non-conditional,
<spot id="aj000035_8a"/>forcing space-specifier computed in terms of the
sequence <var>S'</var>.</p>






<olist>
<item><p>If any of the space-specifiers in <var>S'</var> is conditional,
and begins a reference-area or line-area, then it is <term>suppressed</term>,
which means that its resolved space-specifier is zero. Further, any conditional
space-specifiers which consecutively follow it in the sequence are also suppressed.</p>
<p>If a conditional space-specifier ends a reference-area or line-area, then it
is suppressed together with any other conditional space-specifiers which
consecutively precede it in the sequence.</p></item>
<item><p>If any of the remaining space-specifiers in <var>S'</var> is forcing, all non-forcing
space-specifiers are suppressed, and the value of each of the forcing space-specifiers
is taken as its resolved value.</p></item>
<item><p>Alternatively if all of the remaining space-specifiers in <var>S'</var> are non-forcing,
then the resolved space-specifier is defined in terms of those non-suppressed space-specifiers
whose precedence is numerically highest, and among these those whose optimum value is the
greatest. All other space-specifiers are suppressed. If there is only one of
these then its value is taken as its resolved value.</p>
<p><spot id="js010061_9"/>Otherwise, follow these rules when there are
two or more
space-specifiers all of the same highest precedence and the same
(largest) optimum: The resolved space-specifier of the last
space-specifier in the sequence is derived from these spaces by
taking their common optimum value as its optimum. The greatest of
their minimum values is its minimum. The least of their maximum
values is its  maximum. All other space-specifiers are suppressed.</p>
</item>

<item><p>If

<spot id="jc-20010328-b-p-d-1"/>
<var>S</var> is subject to overconstrainment relaxing,
then its maximum value is set to the actual block-progression-dimension of the
containing block-area. See <specref ref="bpd-slack"/></p></item>

</olist>
<p><emph>Example</emph>. Suppose the sequence of space values occurring at the
beginning of a <spot id="aj000035_7a"/>reference-area is:
first, a space with value 10 points (that is
minimum, optimum, and maximum all equal to 10 points) and conditionality
<code role="value">discard</code>; second, a space with value 4 points and
conditionality <code role="value">retain</code>; and third, a space
with value 5 points and conditionality <code role="value">discard</code>;
all three spaces having precedence zero. Then the first (10 point) space is
suppressed under rule 1, and the
second (4 point) space is suppressed under rule 3. The resolved value of the
third space is a non-conditional 5 points, even though
it originally came from a conditional space.</p>
<p>The padding of a block-area does not interact with <spot id="aj000035_7b"/>any
space-specifier
(except that by definition, the presence of padding at the before- or after-edge
prevents areas on either side of it from having a stacking constraint.)</p>
<p>The border or padding at the before-edge or after-edge of a block-area <var>B</var> may
be specified as conditional. If so, then it is set to zero if its associated
edge is a leading edge in a reference-area, and the is-first trait of <var>B</var>
is false, or if its associated
edge is a trailing edge in a reference-area, and the is-last trait of <var>B</var>
is false. In either of these cases, the border
or padding is taken to be zero for purposes of the stacking constraint definitions.</p>
<p>The border or padding at the start-edge or end-edge of an inline-area <var>I</var> may
be specified as conditional. If so, then it is set to zero if its associated
edge is a leading edge in a line-area, and the is-first trait of <var>I</var>
is false, or if its associated
edge is a trailing edge in a line-area, and the is-last trait of <var>I</var>
is false. In either of these cases, the border
or padding is taken to be zero for purposes of the stacking constraint definitions.</p>
</div3>

<div3 id="bpd-slack"><head>Overconstrained space-specifiers</head>
<p>When

<spot id="jc-20010328-b-p-d-2"/>
an area <var>P</var> is generated by a formatting object whose
block-progression-dimension
is "auto", then the constraints involving the before-edge and after-edge of
the content-rectangle of <var>P</var>, together with the constraints between the
various descendants of <var>P</var>, result in a constraint on the actual value
of the block-progression-dimension. If the block-progression-dimension is instead
specified as a length, then this might result in an overconstrained area tree,
for example an incompletely-filled fo:block
with a specified size. In that case some constraints between <var>P</var> and its
descendants should be relaxed; those that are eligible for this treatment are
said to be <emph>subject to overconstrainment relaxing</emph>, and treated as in
the previous section.</p>
<ulist>
<item><p>If the display-align value is "after" or "center" and <var>P</var> is the first normal area generated
by the formatting object, then the space-before of the first normal child of <var>P</var>
is subject to overconstrainment relaxing.</p></item>
<item><p>If the display-align value is "before" or "center" and <var>P</var> is the last normal area generated
by the formatting object, then the space-after of the last normal child of <var>P</var>
is subject to overconstrainment relaxing.</p></item>
</ulist>
</div3>


</div2>
<div2 id="area-block"><head>Block-areas</head>
<p>Block-areas have several traits which typically affect the placement of their
children. The <term>line-height</term> is used in line placement calculations.
The <trait>line-stacking-strategy</trait> trait controls what kind of allocation
is used for descendant line-areas and has an enumerated value
(either <code role="value">font-height</code>, <code role="value">max-height</code>,
or <code role="value">line-height</code>). This is all rigorously described below.
All areas have these traits,
but they only have relevance for areas which have stacked line-area children.</p>
<p>The <trait>space-before</trait> and <trait>space-after</trait> traits
determine the
distance between the block-area and surrounding block-areas.</p>
<p>A block-area which is not a line-area typically has its size in the
inline-progression-direction determined
by its <trait>start-indent</trait> and <trait>end-indent</trait> and by the size of its nearest ancestor
reference-area.


<spot id="jc-20010328-b-p-d-3"/>
A block-area which is not a line-area must be properly stacked (as defined in
<specref ref="area-stackblock"/> below)
unless otherwise specified in the description of its generating formatting object.
In this case it its block-progression-dimension will be subject to constraints based
on the block-progression-dimensions and space-specifiers of its descendants.
See <specref ref="bpd-slack"/></p>

<div3 id="area-stackblock"><head>Stacked Block-areas</head>
<p>Block-area children of an area are typically stacked in the
block-progression-direction
within their parent area, and this is the default method of
positioning block-areas. However, formatting objects
are free to specify other methods of positioning child areas of areas which
they generate, for example list-items or tables.</p>
<p>For a parent area <var>P</var> whose children are
block-areas, <var>P</var> is defined to be <term>properly
stacked</term> if all of the following conditions hold:</p>
<olist>
<item><p>For each block-area <var>B</var> which is a descendant of <var>P</var>,
the following hold:</p>
<ulist><item><p>the before-edge and after-edge
of its allocation-rectangle are parallel to the before-edge and after-edges of the
content-rectangle of <var>P</var>,</p></item>
<item>
<p>the start-edge of its allocation-rectangle is parallel to the start-edge
of the content-rectangle of <var>R</var> (where <var>R</var> is the closest
ancestor reference-area of <var>B</var>), and offset from it inward
by a distance equal to
the block-area's start-indent plus its
<spot id="fo01jr_2a"/><trait>start-intrusion-adjustment</trait>
<spot id="fosg_1a"/>(as defined below), minus its border-start,
padding-start, and space-start values, and</p></item><item>
<p>the end-edge of its allocation-rectangle is parallel to the
end-edge
of the content-rectangle of <var>R</var>, and offset from it inward
by a distance equal to
the block-area's end-indent plus its
<spot id="fo01jr_2b"/><trait>end-intrusion-adjustment</trait>
<spot id="fosg_1b"/>(as defined below),
minus its border-end, padding-end, and space-end
values.</p></item></ulist>
<figure>
<graphic source="RectsForModel.gif" alt="Metrics of a block area" longdesc="This diagram shows a reference area, with all edges labeled: space-start, border-start and padding-start to the left, space-end, border-end and padding-end to the right, space-before, border-before and padding-before at the top, space-after, border-after and padding-after at the bottom. start-indent is shown, spanning space, border and padding on the left, as well as end-indent, spanning space, border and padding on the right." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p>Content Rectangle of Reference Area</p></figcap>
</figure>
<note><p>The notion of indent is intended to apply to the content-rectangle, but
the constraint is written in terms of the
allocation-rectangle, because as noted earlier

(<specref ref="area-geo"/>)
the edges of the
content-rectangle may not
correspond to like-named edges of the
allocation-rectangle.</p>
<p>The <trait>start-intrusion-adjustment</trait> and
<trait>end-intrusion-adjustment</trait> are traits used to
deal with intrusions from
floats in the inline-progression-direction.</p></note>
</item>
<item><p>For each pair of normal areas <var>B</var> and <var>B</var>'
in the subtree below <var>P</var>, if
<var>B</var> and <var>B</var>' have a block-stacking constraint <var>S</var>

<spot id="jc-20010328-empties3"/>

and <var>B</var> is not empty (see <specref ref="area-stackcon"/>),

then the distance between the adjacent edges of <var>B</var> and <var>B</var>'
is consistent with the
constraint imposed by the
resolved values of the space-specifiers in <var>S</var>.</p>
<graphic source="spacebeforeafter.gif" alt="Example of stacked areas" longdesc="Four areas, P, A, B and C. P contains A and B, stacked vertically, and B contains C. Below A is a 3pt space, above B is a 1pt space, and above C (within B) is a 2pt space." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<p><emph>Example</emph>. In the diagram, if area
<var>A</var>
has a space-after value of 3 points, <var>B</var> a
space-before
of 1 point, and <var>C</var> a space-before of 2 points, all
with
precedence of <code role="value">force</code>, and with zero border and padding,
then the constraints will place <var>B</var>'s
allocation-rectangle
4 points below that of <var>A</var>, and <var>C</var>'s
allocation-rectangle
6 points below that
of <var>A</var>. Thus the 4-point gap receives the
background color
from <var>P</var>, and the 2-point gap before <var>C</var>
receives the background color from <var>B</var>.</p>
</item>
</olist></div3>
<div3 id="intrusadjust"><head>Intrusion Adjustments</head>


<p><spot id="fosg_1c"/>Intrusion adjustments (both start- and end-) are defined to account for the
indentation that occurs as the result of side floats.</p>

<p>If <var>A</var> and <var>B</var> are areas which have the same nearest reference area ancestor, then <var>A</var>
and <var>B</var> are defined to be <term>inline-overlapping</term> if there is some line
parallel to the inline-progression-direction, which intersects both the
allocation-rectangle of <var>A</var> and the allocation-rectangle of <var>B</var>.</p>

<p>If
<spot id="jc-20010327-intrusions"/>

<spot id="jc-20010328-intrusions-1"/>

<spot id="jc-20010501-intrusions"/>

<spot id="jc-20010515-intrusions"/>

<var>A</var> is an area of class <code role="value">xsl-side-float</code> with float="<code role="value">start</code>", and <var>B</var> is a block-area, and <var>A</var> and <var>B</var>
have the same nearest reference area ancestor, then <var>A</var> is defined to <term>encroach</term> upon <var>B</var> if <var>A</var> and <var>B</var>
are inline-overlapping and the start-indent of <var>B</var> is less than the sum of the start-indent of <var>A</var>
and the inline-progression-dimension of <var>A</var>.  The <term>start-encroachment</term> of <var>A</var> on <var>B</var> is then defined to
be amount by which the start-indent of <var>B</var> is less than the sum of the start-indent of <var>A</var> and
the inline-progression-dimension of <var>A</var>.</p>

<p>If <var>A</var> is an area of class <code role="value">xsl-side-float</code> with float="<code role="value">end</code>", and <var>B</var> is a block-area, and <var>A</var> and <var>B</var>
have the same nearest reference area ancestor, then <var>A</var> is defined to <term>encroach</term> upon <var>B</var> if <var>A</var> and <var>B</var>
are inline-overlapping and the end-indent of <var>B</var> is less than the sum of the end-indent of <var>A</var>
and the inline-progression-dimension of <var>A</var>.  The <term>end-encroachment</term> of <var>A</var> on <var>B</var> is then
defined to be amount by which the end-indent of <var>B</var> is less than the sum of the end-indent of <var>A</var> and
the inline-progression-dimension of <var>A</var>.</p>

<p>If <var>B</var> is a block-area which is not a line-area, then its <term>local-start-intrusion-adjustment</term> is computed as the maximum of
the following lengths:</p>

<olist>
<item><p>zero;</p></item>

<item><p>if the parent of <var>B</var> is not a reference area: the start-intrusion-adjustment of the parent of <var>B</var>;
and</p></item>

<item><p>if <var>B</var> has float-displace="<code role="value">block</code>",
then for each area <var>A</var> of class <code role="value">xsl-side-float</code>
with float="<code role="value">start</code>" such that the generating formatting object of <var>A</var> is not a descendant of
the generating formatting object of <var>B</var>, and such that <var>A</var> encroaches upon some line-area child of
<var>B</var>: the start-encroachment of <var>A</var> on <var>B</var>;
and</p></item>

<item><p>if <var>B</var> has float-displace = "<code role="value">block</code>", then for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">start</code>"
such that <var>A</var> and <var>B</var> are inline-overlapping, and for each block-area ancestor <var>B'</var> of <var>B</var> which is
a descendant of the nearest reference area ancestor of <var>B</var>, such that <var>A</var> encroaches on a line-area
child of <var>B'</var>:  the start-encroachment of <var>A</var> on <var>B'</var>.</p></item>

</olist>

<p>The start-intrusion-adjustment of a block-area <var>B</var> is then defined to be
the maximum of the local-start-intrusion-adjustments of the normal block-areas generated
and returned by the generating formatting object of <var>B</var>.</p>

<p>If <var>L</var> is a line-area, then its start-intrusion-adjustment is computed as the maximum of
the following lengths:</p>

<olist>
<item><p>the start-intrusion-adjustment of the parent of <var>L</var>;</p></item>

<item><p>for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">start</code>" such that <var>A</var> encroaches upon <var>L</var>:
the start-encroachment of <var>A</var> on <var>L</var>; and</p></item>

<item><p>if the parent of <var>L</var> has float-displace = "<code role="value">indent</code>",
then for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">start</code>" such that
<var>A</var> and <var>L</var> are inline-overlapping, and for each block-area ancestor <var>B'</var> of <var>L</var> which is
a descendant of the nearest reference area ancestor of <var>L</var>, such that <var>A</var> encroaches on some line-area
child <var>L'</var> of <var>B'</var>:  the start-encroachment of <var>A</var> on <var>B'</var>.</p></item>
</olist>

<p>The end-intrusion-adjustment for a block-area is computed in a precisely analogous manner.
That is:</p>

<p>If <var>B</var> is a block-area which is not a line-area, then its <term>local-end-intrusion-adjustment</term> is computed as the maximum of
the following lengths:</p>

<olist>
<item><p>zero;</p></item>

<item><p>if the parent of <var>B</var> is not a reference area: the end-intrusion-adjustment of the parent of <var>B</var>;
and</p></item>

<item><p>if <var>B</var> has float-displace="<code role="value">block</code>",
then for each area <var>A</var> of class <code role="value">xsl-side-float</code>
with float="<code role="value">end</code>" such that the generating formatting object of <var>A</var> is not a descendant of
the generating formatting object of <var>B</var>, and such that <var>A</var> encroaches upon some line-area child of
<var>B</var>: the end-encroachment of <var>A</var> on <var>B</var>;
and</p></item>

<item><p>if <var>B</var> has float-displace = "<code role="value">block</code>", then for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">end</code>"
such that <var>A</var> and <var>B</var> are inline-overlapping, and for each block-area ancestor <var>B'</var> of <var>B</var> which is
a descendant of the nearest reference area ancestor of <var>B</var>, such that <var>A</var> encroaches on a line-area
child of <var>B'</var>:  the end-encroachment of <var>A</var> on <var>B'</var>.</p></item>

</olist>

<p>The end-intrusion-adjustment of a block-area <var>B</var> is then defined to be
the maximum of the local-end-intrusion-adjustments of the normal block-areas generated
and returned by the generating formatting object of <var>B</var>.</p>

<p>If <var>L</var> is a line-area, then its end-intrusion-adjustment is computed as the maximum of
the following lengths:</p>

<olist>
<item><p>the end-intrusion-adjustment of the parent of <var>L</var>;</p></item>

<item><p>for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">end</code>" such that <var>A</var> encroaches upon <var>L</var>:
the end-encroachment of <var>A</var> on <var>L</var>; and</p></item>

<item><p>if the parent of <var>L</var> has float-displace = "<code role="value">indent</code>",
then for each area <var>A</var> of class <code role="value">xsl-side-float</code> with float="<code role="value">end</code>" such that
<var>A</var> and <var>L</var> are inline-overlapping, and for each block-area ancestor <var>B'</var> of <var>L</var> which is
a descendant of the nearest reference area ancestor of <var>L</var>, such that <var>A</var> encroaches on some line-area
child <var>L'</var> of <var>B'</var>:  the end-encroachment of <var>A</var> on <var>B'</var>.</p></item>
</olist>



</div3>
</div2>
<div2 id="area-line"><head>Line-areas</head>
<p>A line-area is a special type of block-area, and is generated by the same
formatting object which generated
its parent. Line-areas do not have borders and padding, i.e., border-before-width,
padding-before-width, etc. are all zero. Inline-areas are stacked within a line-area
relative to a <term>baseline-start-point</term> which is a point determined by the
formatter, on the start-edge of the line area's content-rectangle.</p>
<p>The allocation-rectangle of a line is determined by the value of the
<trait>line-stacking-strategy</trait> trait: if the
value is <code role="value">font-height</code>, the allocation-rectangle is
the <term>nominal-requested-line-rectangle</term>, defined below; if the value is
<code role="value">max-height</code>, the allocation-rectangle is the
<term>maximum-line-rectangle</term>, defined below; and if
the value is
<code role="value">line-height</code>, the allocation-rectangle is the
<term>per-inline-height-rectangle</term>, defined below.
If the <trait>line-stacking-strategy</trait> trait is <code role="value">font-height</code>
or <code role="value">max-height</code> the <trait>space-before</trait> and <trait>space-after</trait>
are both set to the half-leading value; otherwise they are both set to zero.</p>

<p>The <term>nominal-requested-line-rectangle</term> for a line-area is the rectangle
whose start-edge is parallel to the start-edge of the
content-rectangle of the nearest ancestor reference-area and offset from it by the sum
of the start-indent and the start-intrusion-adjustment of the line area,
whose end-edge is parallel to the end-edge of the
content-rectangle of the nearest ancestor reference-area and offset from it by the sum
of the end-indent and the end-intrusion-adjustment of the line area,
whose before-edge is separated from the
baseline-start-point by the text-altitude of the parent block-area, and whose after-edge is
separated from the baseline-start-point by the text-depth of the parent block-area. It has the
same block-progression-dimension for each line-area child of a block-area.</p>

<p>The <term>maximum-line-rectangle</term> for a line-area is the rectangle
whose start-edge and end-edge are parallel to and coincident with the start-edge
and end-edge of the nominal-requested-line-rectangle, and whose
extent in the block-progression-direction is the minimum required to enclose both the
nominal-requested-line-rectangle and the allocation-rectangles of all the
inline-areas stacked within the line-area; this may vary depending on the
descendants of the line-area.</p>

<figure>
<graphic source="InlineExampleMixed.2a.gif" alt="Nominal and Maximum Line Rectangles" longdesc="A horizontal alignment of inline areas (glyphs and graphics). The maximum-line-rectangle wraps all the glyph areas, the nominal-requested-line-rectangle wraps the glyph areas of the first three glyphs (which use the nominal font). The alignment baseline is shown, splitting the n-r-l-r horizontally. The text-altitude is the vertical distance between the baseline and the top of the n-r-l-r, and the text-depth is the distance between the baseline and the bottom of the n-r-l-r." xml:attributes="href source" show="embed" actuate="auto" xmlns:xlink="http://www.w3.org/TR/WD-xlink"/>
<figcap><p><spot id="fo_sg_08"/>Nominal and Maximum Line Rectangles</p></figcap>
</figure>

<p>The <term>per-inline-height-rectangle</term> for a line-area is the rectangle
whose start-edge and end-edge are parallel to and coincident with the start-edge
and end-edge of the nominal-requested-line-rectangle, and whose extent in the
block-progression-dimension is determined as follows.</p>
<p>The <term>expanded-rectangle</term> of an inline-area is the rectangle with start-edge
and end-edge coincident with those of its allocation-rectangle, and whose
before-edge and after-edge are outside those of its allocation-rectangle by a
distance equal to either (a.) the half-leading, when the area's allocation-rectangle is
specified to be the normal-allocation-rectangle by the description of the generating
formatting object , or (b.) the space-before and space-after (respectively),
when the area's allocation-rectangle is specified to be the large-allocation-rectangle. The
<term>expanded-nominal-requested-line-rectangle</term> is the rectangle with start-edge
and end-edge coincident with those of the nominal-requested-line-rectangle, and whose
before-edge and after-edge are outside those of the nominal-requested-line-rectangle by a
distance equal to the half-leading.</p>
<p>The extent of the
per-inline-height-rectangle in the block-progression-direction is then defined to
be the minimum required to enclose both
the expanded-nominal-requested-line-rectangle and the expanded-rectangles of all the
inline-areas stacked within the line-area; this may vary depending on the
descendants of the line-area.</p>
<note><p>
Using the nominal-requested-line-rectangle allows equal baseline-to-baseline
spacing. Using the maximum-line-rectangle allows constant space between line-areas.
Using the
per-inline-height-rectangle and zero space-before and space-after allows
CSS-style line box stacking. Also, the value of half-leading is included in the
expanded-rectangle regardless of conditionality, and thus a line-height conditionality
of "discard" does not have effect in this case.
</p></note>
</div2>
<div2 id="area-inline"><head>Inline-areas</head>
<p>An inline-area has its own <trait>line-height</trait> trait, which may be
different from the line-height of its containing block-area. This may affect the
placement of its ancestor line-area when the line-stacking-strategy
is <code role="value">line-height</code>. An inline-area has an
<trait>actual-baseline-table</trait>
for its <trait>nominal-font</trait>. It has
a <trait>dominant-baseline-identifier</trait> trait which determines how
its stacked inline-area descendants are to be aligned.</p>
<p>An inline-area may or may not have child areas, and if so it may or may not
be a reference-area. The dimensions of the content-rectangle for an inline-area
without children is computed as specified by the generating formatting object,
as are those of an inline-area with block-area children.</p>
<p>An inline-area with inline-area children has a content-rectangle
which extends from its dominant baseline (see

<specref ref="area-font"/>) by its
text-depth in the block-progression-direction, and in the opposite
direction by its text-altitude; in the inline-progression-direction it
extends from the start-edge of the allocation-rectangle of its first child to
the end-edge of the allocation-rectangle of its last child.  The allocation-rectangle
of such an inline-area is the same as its content-rectangle.</p>
<p>The allocation-rectangle of an inline-area without children is either
the normal-allocation-rectangle or the large-allocation-rectangle, as specified
in the description of the generating formatting object.</p>
<note><p>When the line-stacking-strategy is <code role="value">line-height</code>,
allocation is done with respect to the expanded-rectangle.</p></note>
<p>Examples of inline-areas with children might include portions of inline
mathematical expressions or areas arising from mixed writing systems
(left-to-right within right-to-left, for example).</p>
<div3 id="area-stackinline"><head>Stacked Inline-areas</head>
<p>Inline-area children of an area are typically stacked in the
inline-progression-direction
within their parent area, and this is the default method of
positioning inline-areas.</p>
<p>Inline-areas are stacked relative to the <term>dominant baseline</term>,
as defined above

(<specref ref="area-font"/>).</p>
<p>For a parent area <var>P</var> whose children are inline-areas, <var>P</var>
is defined to be <term>properly stacked</term> if all of the following conditions
hold:</p>
<olist>
<item><p>For each inline-area descendant <var>I</var> of <var>P</var>, the
start-edge, end-edge, before-edge and after-edge of the allocation-rectangle
of <var>I</var> are parallel to corresponding edges of the content-rectangle
of the nearest ancestor reference-area of <var>I</var>.</p></item>
<item><p>For each pair of normal areas <var>I</var> and <var>I</var>'
in the subtree below <var>P</var>, if <var>I</var> and <var>I</var>' have
an inline-stacking constraint <var>S</var>, then the distance between the
adjacent edges of <var>I</var> and <var>I</var>' is consistent with the
constraint imposed by the resolved values of the space-specifiers in
<var>S</var>.</p></item>
<item><p>For any inline-area descendant <var>I</var> of <var>P</var>, the
distance in the shift-direction from the dominant baseline of <var>P</var> to the
alignment-point of <var>I</var> equals the offset between the dominant
baseline
of <var>P</var> and the baseline of <var>P</var> corresponding to the
alignment-baseline trait of <var>I</var>, plus the
sum of the
baseline-shifts for <var>I</var> and all of its ancestors which are
descendants of <var>P</var>.</p><p> The first summand is computed to compensate for
mixed writing systems with different baseline types, and the other
summands involve deliberate baseline shifts for things like superscripts
and subscripts.</p></item>
</olist>
</div3>
<div3 id="area-glyph"><head>Glyph-areas</head>
<p>The most common inline-area is a glyph-area, which contains the
representation for a character (or characters) in a particular font.</p>
<p>A glyph-area has an associated <term>nominal-font</term>, determined by
the area's typographic traits, which apply to its character data, and
a <term>glyph-orientation</term> determined by its writing-mode and
reference-orientation, which determine the orientation of the glyph
when it is rendered.</p>
<p>The alignment-point and dominant-baseline-identifier of a glyph-area are assigned
according to the writing-system in use (e.g., the glyph baseline
in Western languages), and are used to control placement of inline-areas
descendants of a line-area. The formatter may generate inline-areas with
different inline-progression-directions from their parent to accommodate
correct inline-area stacking in the case of mixed writing systems.</p>
<p>A glyph-area has no children. Its block-progression-dimension and
actual-baseline-table are the same for all glyphs in a font.
<spot id="fo_sg_04a"/>Conforming implementations may choose to
compute the block-progression-dimension for a glyph area based on the
actual glyph size rather than using a common size for all glyphs
in a font.</p>
</div3>
</div2>

<div2 id="area-order"><head>Ordering Constraints</head>

<div3 id="area-genorder"><head>General Ordering Constraints</head>

<p>A subset <var>S</var> of the areas returned to a formatting object is
called <term>properly ordered</term> if the areas in that
subset have the
same order as their generating formatting objects.  Specifically, if <var>A</var><sub>1</sub>
and <var>A</var><sub>2</sub> are areas in <var>S</var>, returned by child
formatting objects <var>F</var><sub>1</sub> and <var>F</var><sub>2</sub>
where <var>F</var><sub>1</sub> precedes <var>F</var><sub>2</sub>,
then <var>A</var><sub>1</sub> must precede <var>A</var><sub>2</sub> in the
pre-order traversal order of the area tree. If <var>F</var><sub>1</sub>
equals <var>F</var><sub>2</sub> and <var>A</var><sub>1</sub> is
returned prior to <var>A</var><sub>2</sub>, then <var>A</var><sub>1</sub>
must precede <var>A</var><sub>2</sub> in the pre-order-traversal
of the area tree.
</p>
<p>For each formatting object <var>F</var> and each area-class <var>C</var>,
the subset consisting of the areas returned to <var>F</var> with area-class
<var>C</var> must be properly ordered, except where
otherwise specified.
</p>
</div3>
<div3 id="area-linebuild"><head>Line-building</head>
<p>This section describes the ordering constraints that apply to formatting
an fo:block or similar block-level object.</p>
<p>A block-level formatting object <var>F</var> which
constructs lines does so by
constructing block-areas which it returns to its parent
formatting object, and placing normal areas and/or anchor areas returned to
<var>F</var> by its child
formatting objects as children of those block-areas or of
line-areas
which it constructs as children of those block-areas.</p>
<p>For each such formatting object <var>F</var>, it must be
possible to form an
ordered partition <var>P</var> consisting of ordered subsets <var>S</var><sub>1</sub>,
<var>S</var><sub>2</sub>, ..., <var>S</var><sub><var>n</var></sub> of
the normal areas and anchor areas returned by the child formatting objects,
such that the following are all satisfied:</p>
<olist>
<item><p>Each subset consists of a sequence of inline-areas, or of a single
block-area.</p>
</item>
<item><p>The ordering of the partition follows the ordering of the
formatting object tree. Specifically, if <var>A</var> is in
<var>S</var><sub><var>i</var></sub>
and <var>B</var> is in <var>S</var><sub><var>j</var></sub> with
<var>i</var> &lt; <var>j</var>, or if <var>A</var> and <var>B</var> are both in the same subset
<var>S</var><sub><var>i</var></sub> with <var>A</var> before <var>B</var> in the
subset order, then either <var>A</var> is returned by a preceding sibling
formatting object of <var>B</var>, or <var>A</var> and
<var>B</var> are returned by the same
formatting object with <var>A</var> being returned before
<var>B</var>.</p>
</item>
<item><p>The partitioning occurs at legal line-breaks. Specifically, if <var>A</var> is
the last area of <var>S</var><sub><var>i</var></sub> and <var>B</var> is the first area of
<var>S</var><sub><var>i</var>+1</sub>, then the rules of
the language and script in effect must permit a line-break
between <var>A</var> and
<var>B</var>, within the context of all areas in <var>S</var><sub><var>i</var></sub>
and <var>S</var><sub><var>i</var>+1</sub>.</p>
</item>
<item><p>Forced line-breaks are respected. Specifically, if <var>A</var> is the glyph-area
generated by a fo:character whose Unicode character is U+000A, then <var>A</var> must
be the last area in its containing subset <var>S</var><sub><var>i</var></sub>.</p></item>
<item><p>The partition follows the ordering of the area
tree, except for
certain glyph substitutions and deletions.  Specifically, if <var>B</var><sub>1</sub>,
<var>B</var><sub>2</sub>, ..., <var>B</var><sub><var>p</var></sub> are the normal
child areas of the area
or areas returned by <var>F</var>, (ordered in the pre-order traversal order of the
area tree) then there is a one-to-one correspondence between
these child areas
and the partition subsets (i.e., <var>n</var> = <var>p</var>), and for each <var>i</var>,</p>
<ulist>
<item><p>if <var>S</var><sub><var>i</var></sub> consists of a single block-area then
<var>B</var><sub><var>i</var></sub> is that block-area, and</p></item>
<item><p>if <var>S</var><sub><var>i</var></sub> consists of inline-areas then
<var>B</var><sub><var>i</var></sub> is a line-area whose child areas are the
same as the inline-areas in <var>S</var><sub><var>i</var></sub>, and in the same order,
except that where the rules of the language and script in effect call
for glyph-areas to be substituted, inserted, or deleted, then the
substituted or inserted glyph-areas appear in the area tree in the
corresponding place, and the deleted glyph-areas do not appear in the
area tree.
<spot id="fosg_0c"/>Deletions occur when a glyph-area which is last
within a subset <var>S</var><sub><var>i</var></sub>, has a
<trait>suppress-at-line-break</trait> value of <code role="value">suppress</code>,
provided that <var>i</var> &lt; <var>n</var> and <var>B</var><sub><var>i</var>+1</sub> is
a line-area.  Deletions also occur when a glyph-area which is first within a subset
<var>S</var><sub><var>i</var></sub>,
has a <trait>suppress-at-line-break</trait> value of <code role="value">suppress</code>,
provided that <var>i</var> &gt; 1 and <var>B</var><sub><var>i</var>-1</sub> is a line-area.
Insertions and substitutions may
occur because of addition of hyphens or spelling changes due to
hyphenation, or glyph image construction from syllabification, or
ligature formation.</p></item>
</ulist>
</item>
</olist>
<p>Substitutions that replace a sequence of glyph-areas with a single
glyph-area should only occur when the margin, border, and padding in the
inline-progression-direction (start- and end-), baseline-shift, and
letter-spacing values are zero, treat-as-word-space is
<code role="value">false</code>, and the
values of all other relevant traits match (i.e.,
alignment-adjust, alignment-baseline, color
trait, background traits, dominant-baseline-identifier, font traits,
text-depth,
text-altitude, glyph-orientation-horizontal,
glyph-orientation-vertical, line-height, line-height-shift-adjustment,
text-decoration, text-shadow).</p>
<note><p>Line-areas do not receive the background traits or text-decoration
of their generating formatting object, or any other trait that requires
generation of a mark during rendering.</p></note>
</div3>


<div3 id="area-inlinebuild"><head>Inline-building</head>
<p>This section describes the ordering constraints that apply to formatting
an fo:inline or similar inline-level object.</p>
<p>An inline-level formatting object <var>F</var> which
constructs one or more inline-areas does so by
placing normal inline-areas and/or anchor inline-areas returned to <var>F</var> by its child
formatting objects as children of inline-areas which it
generates.</p>
<p>For each such formatting object <var>F</var>, it must be
possible to form an
ordered partition <var>P</var> consisting of ordered subsets <var>S</var><sub>1</sub>,
<var>S</var><sub>2</sub>, ..., <var>S</var><sub><var>n</var></sub> of
the normal and/or anchor inline-areas returned by the child formatting
objects, such that the following are all satisfied:</p>
<olist>
<item><p><spot id="fo0001_16c"/>Each subset consists of a sequence of inline-areas,
or of a single block-area.</p>
</item>
<item><p><spot id="fo0001_16d"/>The ordering of the partition follows
the ordering of the formatting object tree, as defined above.</p>
</item>
<item><p><spot id="fo0001_16e"/>The partitioning occurs at legal line-breaks, as defined above.</p>
</item>
<item><p>Forced line-breaks are respected, as defined above.</p>
</item>
<item><p><spot id="fo0001_16f"/>The partition follows the ordering of the area tree,
except for certain glyph substitutions and deletions, as
defined above.</p>
</item>
</olist>
</div3>
</div2>

<div2 id="keepbreak"><head>Keeps and Breaks</head>
<p>Keep and break conditions apply to a class of areas, which are typically
page-reference-areas,
column-areas, and line-areas.  The appropriate class for a given condition is referred
to as a <term>context</term> and an area in this class is a <term>context-area</term>.
As defined in Section <specref ref="pag-intro"/>, <term>page-reference-areas</term> are
areas generated by an fo:page-sequence using the
specifications in a fo:page-master, and
<spot id="fosg_2a"/><term>column-areas</term> are
normal-flow-reference-areas generated from a region-body, or
region-reference-areas generated from other types of region-master.</p>
<p>A keep or break condition is an open statement about a formatting object and the
tree relationships of the areas it generates with the relevant context-areas. These
tree relationships are defined mainly in terms of <term>leading</term> or <term>trailing</term>
areas.  If <var>A</var> is a descendant of <var>P</var>, then <var>A</var> is defined to
be <term>leading</term> in <var>P</var> if <var>A</var> has no preceding sibling which
is a normal area, nor does any of its ancestor areas up to but not including
<var>P</var>.  Similarly, <var>A</var> is defined to
be <term>trailing</term> in <var>P</var> if <var>A</var> has no following sibling which
is a normal area, nor does any of its ancestor areas up to but not including
<var>P</var>. For any given formatting object, the <term>next</term> formatting object
in the flow is the first formatting object following (in the pre-order traversal order)
which is not a descendant of the given formatting object and
which generates and returns normal areas.</p>
<p>Break conditions are either break-before or break-after conditions.  A break-before
condition is <term>satisfied</term> if the first area generated and returned
by the formatting object is
leading within a context-area. A break-after condition
depends on the next formatting object in
the flow; <spot id="se010003_2"/>the condition
is satisfied if either there is no such next formatting object, or if the
first normal area generated and returned by that formatting object is leading in a context-area.</p>
<p>Break conditions are imposed by the <trait>break-before</trait> and
<trait>break-after</trait> properties. A
refined value of <code role="value">page</code> for these traits imposes a
break condition with a context
consisting of the page-reference-areas; a value of <code role="value">even-page</code>
or <code role="value">odd-page</code> imposes a
break condition with a context of even-numbered page-reference-areas
or odd-numbered
page-reference-areas, respectively; a value of <code role="value">column</code> imposes a
break condition with a
context of column-areas. A value of <code role="value">auto</code> in a
break-before or break-after
trait imposes no break condition.</p>
<p>Keep conditions are either keep-with-previous, keep-with-next, or keep-together
conditions.  A keep-with-previous condition on an object is satisfied if the first
area generated and returned by the formatting object is not leading within a
context-area, or if
there are no preceding areas in a post-order traversal of the area tree.  A
keep-with-next condition is satisfied if the last area generated and returned by the
formatting object is not trailing within a context-area, or
if there are
no following areas in a pre-order traversal of the area tree.  A keep-together
condition is satisfied if all areas generated and returned by the formatting object are
descendants of a single context-area.</p>
<p>Keep conditions are imposed by the "within-page", "within-column", and "within-line" components
of the "keep-with-previous", "keep-with-next", and
<spot id="fo0001jc_a"/>"keep-together" properties.
The refined value of each component specifies the <term>strength</term> of the keep condition
imposed, with higher numbers being stronger than lower numbers and the value
<code role="value">always</code> being stronger than all numeric values.
A component with value <code role="value">auto</code>
does not impose a keep condition.  A "within-page" component imposes a keep-condition
with context consisting of the page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the line-areas.</p>
<p>The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would cause a
break condition or a stronger keep condition to fail to be satisfied. If not
all of a set of keep conditions of equal strength can be satisfied, then some
maximal satisfiable subset of conditions of that strength
must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).</p>
</div2>

<div2 id="rendmodel"><head>Rendering Model</head>
<p>
This section makes explicit the relationship between the area tree
and visually rendered output.
</p>
<p>
Areas generate three types of marks: (1) the area
background, if any, (2) the marks
intrinsic to the area (a glyph, image, or decoration) if any, and (3) the
area border, if any.
</p>
<p>
An area tree is rendered by causing marks to appear on an output medium in
accordance with the areas in the area tree.  This section describes the
geometric location of such marks, and how conflicts between marks are to
be resolved.
</p>
<div3 id="rend-geo"><head>Geometry</head>
<p>
Each area is rendered in a particular location. Formatting object semantics
describe the location of intrinsic marks relative to the object's location,
i.e., the left, right, top, and bottom edges of its content-rectangle. This
section describes how the area's location is determined,
which determines the location of its intrinsic m