Back to SpaceResolution.

/!\ Please note that this page was not updated after the clarification about space traits by the XSL FO SG!!! /!\

Example 0

This is the one from the spec (in chapter 4.3.1).

<fo:block space-before="10pt">
  <fo:block space-before="4pt" space-before.conditionality="retain">
    <fo:block space-before="5pt">
      <fo:block>before break</fo:block>
      <fo:block>after break</fo:block>
    </fo:block>
  </fo:block>
</fo:block>

For both cases, break before the above sequence and between "before break" and "after break":

The 10pt space is suppressed due to rule 1. It is conditional and begins a reference area.

The rest of the spaces are non-forcing, so rule 2 is skipped.

The 4pt space is suppressed under rule 3. It has the same precedence as the 5pt space but has a smaller optimum length. Since there will only be one resolved space it will be 5pt.

Example 1

A simple (conditional) space.

<fo:block>first line</fo:block>
<fo:block space-before="10pt">
  <fo:block>before break</fo:block>
  <fo:block>after break</fo:block>
</fo:block>

The break after "first line" does not produce a 10pt space because the space is conditional.

The break after "break before" does not produce a 10pt space because the space is conditional.

Element list:

box w=lh for "first line"

penalty w=0 p=0 for the break possibility after "first line"

aux glue w=10pt for the space in case there is no break

box w=lh for "before break"

penalty w=0 p=0 for the break possibility after "before break"

box w=lh for "after break"

Example 2

A non-conditional space.

<fo:block>first line</fo:block>
<fo:block space-before="10pt" space-before.conditionality="retain">
  <fo:block>before break</fo:block>
  <fo:block>after break</fo:block>
</fo:block>

The break after "first line" produces a 10pt space because the space is retained.

The break after "break before" produces a 10pt space because the space is retained.

Element list:

box w=lh for first block

penalty w=0 p=0 for the break possibility

box w=0
penalty p=INF
aux glue w=10pt for space-before

box w=lh for "before break"

penalty w=0 p=0 for the break possibility after "before break"

aux glue w=-10pt for compensating the space glue below in the no-break condition

box w=0
penalty p=INF
aux glue w=10pt for space-before

box w=lh for "after break"

Example 3

The collapsing of the adjacent conditional spaces according to rule 3.

<fo:block space-after="10pt">first block</fo:block>
<fo:block space-before="10pt">second block</fo:block>

Break between the blocks:

We have two S' which each contains one space specifier.

S'[1]: The space-after on the first block is suppressed under rule 1 in 4.3.1.

S'[2]: The space-before on the second block is suppressed under rule 1 in 4.3.1.

No break between the blocks:

S' consists of both space-specifiers in this example (Case 3a under 4.2.5. Stacking Constraints).

Rule 1 does not apply. No forcing space-specifiers (rule 2). Both non-forcing space-specifiers collapse to a single space with 10pt.

Element list:

box w=lh for first block

penalty w=0 p=0 for the break possibility

glue w=10pt y=0 z=0

box w=lh for second block

Example 4

<fo:block space-after="10pt" space-after.conditionality="retain">first block</fo:block>
<fo:block space-before="10pt">second block</fo:block>

Break between the blocks:

The first space specifier is retained. The second is conditional and is suppressed.

Element list:

box w=lh for first block

glue w=10pt y=0 z=0

penalty w=0 p=0 for the break possibility

box w=lh for second block

Example 5

<fo:block space-after="10pt" space-after.conditionality="retain">first block</fo:block>
<fo:block space-before="10pt" space-before.conditionality="retain">second block</fo:block>

Break between the blocks:

Both space specifiers are retained.

That means that with a break we have more space than without a break, and we need a negative glue (glue #2) to compensate this.

Element list:

(the full case: glue #1 - penalty - glue #2 - box - PENALTY - glue #3):

box w=lh for first block

glue w=10pt y=0 z=0

penalty w=0 p=0 for the break possibility

glue w=-10pt y=0 z=0

box w=0
penalty w=0 p=INF
glue w=10pt y=0 z=0

box w=lh for second block

Example 6 and 7 removed due to mistakes.

Example 8

Bringing border and padding into play.

<fo:block space-before="10pt" padding-before="5pt" border-before-style="solid" border-before-width="2pt">
  first line
  <fo:block space-before="6pt">second line</fo:block>
</fo:block>

We look at the break possibility between the first and the second line here. All spaces, paddings and borders are conditional. Since the block area for "second line" begins a reference-area here, according to 4.3.1, the widths for border and padding from the parent block both collapse to zero, so S' consists of both space-specifiers in this example. Both space-specifiers are conditional and are therefore suppressed under rule 1, as they have a stacking constraint when border and padding collapse to zero.

Only in the non-break condition will the second space-before be generated.

Element list:

box w=lh for first line

penalty w=0 p=0 for the break possibility

aux glue w=6pt y=0 z=0

box w=lh for second line

Example 9

Bringing border and padding into play (continued).

<fo:block space-before="10pt" padding-before="5pt" border-before-style="solid" border-before-width="2pt" border-before-width.conditionality="retain">
  first line
  <fo:block space-before="6pt">second line</fo:block>
</fo:block>

Again we look at the break possibilty between the first and second line as in the previous example. All spaces and paddings are conditional. Only the border is non-conditional (the only change to the previous example). In the break case, we begin a reference-area here, but the border interrupts the suppressing of space elements (there's no stacking constraint anymore). So only the first space-before is suppressed. After that the border is added. The following padding is suppressed, but not the space after that (it does not begin a reference area because of the retained outer border).

In the no-break case, there is simply a 6pt space-before before "second line".

Element list:

box w=0
penalty p=INF
glue w=17pt (10pt space-before + 2pt border + 5pt padding)

box w=lh for "first line"

penalty w=0 p=0 for the break possibility

glue w=-2pt (8pt - 2pt = 6pt for the space-before in the no-break case)

box w=0
penalty p=INF
glue w=8pt (2pt border + 6pt space-before)

box w=lh for "second line"

SpaceResolution/Examples (last edited 2009-09-20 23:52:11 by localhost)