Inheritance

Contact Us or call 1-877-932-8228
Inheritance

Inheritance

Many properties are inherited from parent or ancestor FOs. For example, if you set the font-family in the page-sequence FO, all text in descendant FOs will be in that font family unless it is overridden by a closer ancestor. Generally, properties that you would think should inherit (e.g, font properties, colors, alignment, etc.) do inherit. The example below illustrates inheritance.

Code Sample:

BlocksAndInlines/Demos/Inheritance.fo
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page" page-height="11in" page-width="8.5in" margin="1in">
			<fo:region-body margin=".5in"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="18pt" font-weight="bold" start-indent="1cm">
		<fo:flow flow-name="xsl-region-body">
				<fo:block space-after=".5cm">
					Hello World!
				</fo:block>
				<fo:block space-after=".5cm" font-weight="normal" start-indent="0cm">
					Hello World!
				</fo:block>
				<fo:block>
					Hello <fo:inline font-weight="normal">World</fo:inline>!
				</fo:block>
		</fo:flow>
	</fo:page-sequence>
</fo:root>

The output is shown below:

wrapper

In some cases, you will have large sections of a printed document that needs to be formatted differently from the main document. The wrapper FO is used to assign values to inheriting properties. It can be used in an inline or block element and does not contain its own direct content.

Code Sample:

BlocksAndInlines/Demos/Wrapper.fo
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="page" page-height="11in" page-width="8.5in" margin="1in">
			<fo:region-body margin=".5in"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="page" font-size="18pt" font-weight="bold" start-indent="1cm">
		<fo:flow flow-name="xsl-region-body">
				<fo:block space-after=".5cm">
					Hello World!
				</fo:block>
				<fo:wrapper text-decoration="underline">
					<fo:block space-after=".5cm" font-weight="normal" start-indent="0cm">
						Hello World!
					</fo:block>
					<fo:block>
						<fo:wrapper color="silver">Hello <fo:inline font-weight="normal">World</fo:inline></fo:wrapper>!
					</fo:block>
				</fo:wrapper>
		</fo:flow>
	</fo:page-sequence>
</fo:root>

The output is shown below:

Next