xsl-fo, position of blocks

Positioning

1. Positioning properties
2. Vertical alignment of fo:inlines
3. position property; relative and absolute

1.

Positioning properties

Paul Tchistopolskii

Q: Expansion.
> I can understand the properties of a block about his position.
> I can have a relative, absolute, fixed etc. position. 
> Can I have an absolute position only inside another fo:block ?

Absolute position is calculated with respect to the *containing
block*. For instance, if your element is a direct child of a fo:flow |
fo:static-content, then the position is calculated with respect to the
correspondent region on the page, set by the region-body or any of the
side regions.

            

2.

Vertical alignment of fo:inlines

Victor Vishnyakov



> I want to do the following:

> I need one textline with different font-families and/or font-sizes. I 
> managed this problem with using fo:inline elements within a fo:block.

> now I need to vertically center all fo:inline elements. so, for 
> example, I have the text "big letters" with font-size="2.0mm" directly 
> followed by the text "small letters" with font-size="1.0mm". I need 
> the text "small letters" to appear vertically centered.

Take a look at "7.13.2. alignment-baseline" chapter in the XSL-FO specification. The value "central" or "middle" is might be what you are looking for.

3.

position property; relative and absolute

W. Eliot Kimber




>> position= isn't an FO property (probably meant absolute-position=) 
>> but in any case only block-container can be absolutely positioned.


> It's a shorthand (sect. 7.29.20). 

Ah, I hadn't noticed this shorthand. But it is a shorthand that maps to either absolute-position or relative-position. As absolute-position only applies to block-container and relative-position explicitly does not apply to block-container, this must mean that position maps to relative-position when used on fo:block.

> I can't find the restriction that
> only block-containers may be absolutely positioned in the spec, can 
> you help me here?

The absolute-position property only applies to block-container. Section 7.5.1.

However, reading the description relative-position I'm not 100% clear what it means for blocks. My initial reading is that it has no effect but I also grant that the description is confusing at best.

Doing an experiment with XEP 3.77 and XSL Formatter 2.5 it appears that relative-position has no effect on blocks. My test instance is below. The first two blocks format the same with XSL Formatter. With XEP, the second block is only 2in wide (the 1.0 spec is ambiguous about whether width= is meaningful on fo:block). The second two blocks are formatted with identical positioning by both formatters.

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="mypage"
         page-height="11in"
         page-width="8.5in">
       <fo:region-body
           margin-left="20pt"
           margin-right="20pt"
           margin-top="20pt"
           margin-bottom="20pt"
           border-width="0.5pt"
           border-color="blue"
           border-style="solid"
       />
     </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="mypage">
     <fo:flow flow-name="xsl-region-body"
         font-family="sans-serif">
       <fo:block
         >Test of relative-position on blocks.</fo:block>
       <fo:block left="10pt"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
       >Block with left=10pt</fo:block>

       <fo:block
           left="1in"
           width="2in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="relative"
       >Block with width=2in left=1in and
relative-position="relative"</fo:block>
       <fo:block
           left="1in"
           width="2in"
           margin-left="0.5in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="relative"
       >Block with width=2in left=1in margin-start="0.5in" and
relative-position="relative"</fo:block>
       <fo:block
           left="1in"
           width="2in"
           margin-left="0.5in"
           space-before="12pt"
           background-color="silver"
           border-width="1pt"
           border-color="red"
           border-style="solid"
           relative-position="static"
       >Block with width=2in left=1in margin-start="0.5in" and
relative-position="static"</fo:block>
     </fo:flow>
   </fo:page-sequence>
</fo:root>