| <?xml version="1.0" encoding="utf-8"?> |
| |
| |
| <!-- example for a simple fo file. At the beginning the page layout is set. |
| Below fo:root there is always |
| - a single fo:layout-master-set which defines one or more page layouts |
| - an optional fo:declarations, |
| - and a sequence of one or more fo:page-sequences containing the text and formatting instructions --> |
| |
| <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> |
| |
| <fo:layout-master-set> |
| |
| <!-- layout for the first page --> |
| <fo:simple-page-master master-name="first" |
| page-height="29.7cm" |
| page-width="21cm" |
| margin-top="1cm" |
| margin-bottom="2cm" |
| margin-left="2.0cm + 0.5cm" |
| margin-right="(5cm * 1cm) div 2cm"> |
| <fo:region-body margin-top="3cm"/> |
| <fo:region-before extent="3cm"/> |
| <fo:region-after extent="1.5cm"/> |
| </fo:simple-page-master> |
| |
| <!-- layout for the other pages --> |
| <fo:simple-page-master master-name="rest" |
| page-height="abs(-30cm + .3cm)" |
| page-width="(10cm * 2) + 1cm" |
| margin-top="round(.5) * 1cm" |
| margin-bottom="round(2.4) * 1cm" |
| margin-left="2.5 * 1cm" |
| margin-right="5.5cm - 3cm"> |
| <fo:region-body margin-top="2.5cm"/> |
| <fo:region-before extent="2.5cm"/> |
| <fo:region-after extent="1.5cm"/> |
| </fo:simple-page-master> |
| |
| <fo:page-sequence-master master-name="basicPSM" > |
| <fo:repeatable-page-master-alternatives> |
| <fo:conditional-page-master-reference master-reference="first" |
| page-position="first" /> |
| <fo:conditional-page-master-reference master-reference="rest" |
| page-position="rest" /> |
| <!-- recommended fallback procedure --> |
| <fo:conditional-page-master-reference master-reference="rest" /> |
| </fo:repeatable-page-master-alternatives> |
| </fo:page-sequence-master> |
| |
| </fo:layout-master-set> |
| <!-- end: defines page layout --> |
| |
| <!-- actual layout --> |
| <fo:page-sequence master-reference="basicPSM"> |
| |
| <!-- header --> |
| <fo:static-content flow-name="xsl-region-before"> |
| <fo:block text-align="end" |
| font-size="10pt" |
| font-family="serif" |
| line-height="1em + 4pt" > |
| Property Function Tests - p. <fo:page-number/> |
| </fo:block> |
| </fo:static-content> |
| |
| <fo:flow flow-name="xsl-region-body"> |
| |
| <!-- defines text title level 1--> |
| <fo:block font-size="min(18pt,20pt)" |
| font-family="sans-serif" |
| line-height="max(24pt,18pt)" |
| space-after.optimum="5 mod 3 * 7.5pt" |
| background-color="rgb(0,0,255)" |
| color="rgb(255,255,255)" |
| text-align="center" |
| padding-top="3pt"> |
| Property Function Tests |
| </fo:block> |
| |
| <!-- defines text title level 2--> |
| <fo:block font-size="floor(16.3) * 1pt" |
| font-family="sans-serif" |
| line-height="2pt * ceiling(9.3)" |
| space-before.optimum="10pt" |
| space-after.optimum="10pt" |
| text-align="start" |
| keep-with-next.within-page="always" |
| keep-together.within-page="always" |
| padding-top="3pt"> |
| Function: object from-parent( <fo:inline font-weight='bold'>NCName</fo:inline>) |
| </fo:block> |
| |
| <!-- Normal text --> |
| <fo:block font-size="12pt" |
| font-family="sans-serif" |
| line-height="1.25em" |
| space-after="3pt" |
| keep-together="auto" |
| text-align="start"> |
| The from-parent function returns a computed value of the property |
| whose name matches the argument specified. The value returned is that |
| for the parent of the formatting object for which the expression is |
| evaluated. If there is no parent, the value returned is the initial |
| value. If the argument specifies a shorthand property and if the |
| expression only consists of the from-parent function with an argument |
| matching the property being computed, it is interpreted as an |
| expansion of the shorthand with each property into which the shorthand |
| expands, each having a value of from-parent with an argument matching |
| the property. It is an error if arguments matching a shorthand |
| property are used in any other way. |
| <fo:block font-size="from-parent(font-size) - 2pt" |
| font-family="sans-serif" |
| space-before="from-parent(space-after)" |
| text-align="center"> |
| Here is a nested block with font-size = |
| from-parent(font-size) - 2pt. |
| Since its parent has font-size=12pt, that should mean 10pt. It should |
| keep the line height of 1.25em, which means 12.5pt leading. It's |
| space-before value is set to the space-after value from its |
| parent. Note that neither of these are inheritable. Does it look right? |
| </fo:block> |
| <fo:block font-size="from-parent(font-size) + 2pt" |
| space-before="2pt" |
| space-after="from-parent(space-after)" |
| font-family="sans-serif" |
| start-indent="from-parent(start-indent) + 1cm" |
| end-indent="from-parent(end-indent) + 1cm" |
| text-align="end" |
| background-color="black" color="rgb(50%,50%,50%)"> |
| Here is a nested block with text 2pt larger than its parent (that |
| should be 14pt). This parent is indented 1cm on both start and end |
| directions with respect to the values from its parent (which aren't |
| specified, so they default to 0.0). The color is set to 50% (using the |
| rgb function with % arguements, and the background color for this |
| block is black (specified as a keyword). In this block, we'll put an |
| <fo:inline color='inherited-property-value(background-color)' |
| background-color='inherited-property-value(color)'>inline object</fo:inline> |
| whose background and foreground colors invert those of its containing |
| block. This uses the <fo:inline |
| font-style='oblique'>inherited-property-value</fo:inline> |
| function. Here's an <fo:inline color='black' background-color='white'>inline |
| object</fo:inline> with fixed colors (black on white). That doesn't |
| work either. Guess it's not my problem ... So let's try it with font |
| sizes. In this block, we'll put an |
| <fo:inline font-size='inherited-property-value(font-size)+2pt'>inline |
| object whose font-size is 2 pt bigger than its parent's font-size.</fo:inline></fo:block> |
| </fo:block> |
| <fo:block font-size="12pt" |
| space-before="6pt" |
| line-height="1em + 2pt" |
| font-family="sans-serif" |
| text-align="start" |
| background-color="rgb(50%,50%,50%)"> |
| An outer block with 12 pt text on 14 pt leading, default color |
| and 50% grey background color. Test inherited color changes with |
| nested blocks. |
| <fo:block color='from-parent(background-color)' |
| background-color='from-parent(color)'> |
| Interchange color and background color using from-parent function. |
| </fo:block> |
| </fo:block> |
| |
| </fo:flow> |
| </fo:page-sequence> |
| </fo:root> |