XSL-FO output goes into blocks.
XSL-FO 结果将输入块状区域。
XSL-FO Pages, Flow, and Block
XSL-FO 页面、流程 以及 块状区域
"Blocks" of content "Flow" into "Pages" of the output media.
“块状区域”的内容首先进入“页面”,然后再由指定的媒体输出。
XSL-FO output is normally nested inside <fo:block> elements, nested inside <fo:flow> elements, nested inside <fo:page-sequence> elements:
XSL-FO 的输出结果通常被嵌套在<fo:block>元素、<fo:flow>元素、以及<fo:page-sequence>元素中,具体如下:
<fo:page-sequence> <fo:flow flow-name="xsl-region-body"> <fo:block> <!-- Output goes here --> </fo:block>
</fo:flow> </fo:page-sequence> |
Block Area Attributes
Block 区域属性
Blocks are sequences of output in rectangular boxes:
块状区域包含矩形框内的结果序列:
<fo:block border-width="1mm"> This block of output will have a one millimeter border around it. </fo:block> |
Since block areas are rectangular boxes, they share many common area properties:
因为块状区域的是矩形框,它们共享很多共同的区域性质:
- space before and space after 最上端边界和最下端边界
- margin 边界
- border 边框
- padding 补白
The space before and space after is the empty space separating the block from the other blocks.
“Space before [顶端空间]” 和 “space after [底端空间]” 是用来分隔其它块状区域的空白空间。
The margin is the empty area on the outside of the block.
“margin [边界]” 是块状区域外部的空白区域。
The border is the rectangle drawn around the external edge of the area. It can have different widths on all four sides. It can also be filled with different colors and background images.
“border [边框]”是矩形框的四条边;它们可以有不同的宽度;它们也可以填充不同的颜色和背景图片
The padding is the area between the border and the content area.
“padding [补白]”是位于边框和内容区域之间的地方。
The content area contains the actual content like text, pictures, graphics, or whatever.
“content [内容]” 区域包含了类似于文本、图片、图表等实际存在的内容。
Block Margin
块状区域边界
- margin
四边边界 - margin-top
顶部边界 - margin-bottom
底部边界 - margin-left
左边界 - margin-right
右边界
Block Border
块状区域边框
Border style attributes:
边框样式属性:
- border-style
边框样式 - border-before-style
顶端边框样式 - border-after-style
底端边框样式 - border-start-style
左端边框样式 - border-end-style
右端边框样式 - border-top-style (same as border-before)
顶端边框样式(和 border-before 相同) - border-bottom-style (same as border-after)
底端边框样式(边 border-after 相同) - border-left-style (same as border-start)
左端边框样式(和 border-start 相同) - border-right-style (same as border-end)
右端边框样式(和 border-end 相同)
Border color attributes:
边框颜色属性:
- border-color
边框颜色 - border-before-color
顶端边框颜色 - border-after-color
底端边框颜色 - border-start-color
左端边框颜色 - border-end-color
右端边框颜色 - border-top-color (same as border-before)
顶端边框颜色(和 border-before 相同) - border-bottom-color (same as border-after)
底端边框颜色(和 border-after 相同) - border-left-color (same as border-start)
左端边框颜色(和 border-start 相同) - border-right-color (same as border-end)
右端边框颜色(和 border-end 相同)
Border width attributes:
边框宽度属性:
- border-width
边框宽度 - border-before-width
顶端边框宽度 - border-after-width
底端边框宽度 - border-start-width
左端边框宽度 - border-end-width
右端边框宽度 - border-top-width (same as border-before)
顶端边框宽度(和 border-before 相同) - border-bottom-width (same as border-after)
底端边框宽度(和 border-after 相同) - border-left-width (same as border-start)
左端边框宽度(和 border-start 相同) - border-right-width (same as border-end)
右端边框宽度(和 border-end 相同)
Block Padding
块状区域补白
- padding
补白 - padding-before
顶端补白 - padding-after
底端补白 - padding-start
左端补白 - padding-end
右端补白 - padding-top (same as padding-before)
顶端补白(和 padding-before 相同) - padding-bottom (same as padding-after)
底端补白(和 padding-after 相同) - padding-left (same as padding-start)
左端补白(和 padding-start 相同) - padding-right (same as padding-end)
右端补白(和 padding-end 相同)
Block Background
块状区域背景
- background-color
背景颜色 - background-image
背景图形 - background-repeat
背景重复 - background-attachment (scroll or fixed)
背景滚动设置(scroll:随页面滚动而滚动;fixed:不随页面滚动而滚动)
Block Styling Attributes
块状区域样式属性
Blocks are sequences of output that can be styled individually:
块状区域包含了可以单独定义样式的结果序列:
<fo:block font-size="12pt"
font-family="sans-serif"> This block of output will be written in a 12pt sans-serif font. </fo:block> |
Font attributes:
字体属性:
- font-family
字体 - font-weight
字体粗细 - font-style
字形 - font-size
字体尺寸 - font-variant
字体变量
Text attributes:
文本属性:
- text-align
文本排列 - text-align-last
文本排列持续 - text-indent
文本缩进 - start-indent
顶端缩进 - end-indent
底端缩进 - wrap-option (defines word wrap)
嵌套选项(定义自动换行) - break-before (defines page breaks)
页面左端换行(定义页面换行) - break-after (defines page breaks)
页面右端换行(定义页面换行) - reference-orientation (defines text rotation in 90" increments)
参考定位(定义90度内的文本旋转)
Example
举例
<fo:block font-size="14pt" font-family="verdana" color="red" space-before="5mm" space-after="5mm">
W3Schools </fo:block> <fo:block text-indent="5mm" font-family="verdana" font-size="12pt" space-before="5mm" space-after="5mm">
At ruanchen.com you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP. </fo:block> |
Result:
结果
ruanchen At ruanchen.com you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP. |
When you look at the example above, you can see that it will take a lot of code to produce a document with many headers and paragraphs.
从上述案例中,你会发现,要创建一份包含多个标题和段落的文档需要使用大量的代码。
Normally XSL-FO document do not combine formatting information and content like we have done here.
一般情况下,XSL-FO文档不需要将格式化信息和内容结合起来。
With a little help from XSLT we can put the formatting information into templates and write a cleaner content.
只需要使用XSLT的一小部分功能,我们就可以把格式化信息放入模板中,书写一份整洁的内容了。
You will learn more about how to combine XSL-FO with XSLT templates in a later chapter in this tutorial.
当你学完这份教程之后,你就会掌握更多关于把XSL-FO和XSLT模板结合起来使用的方法。