XSL-FO 的輸出位于塊區(qū)域中。
XSL-FO 頁面(Page)、流(Flow)以及塊(Block)
內(nèi)容"塊"會"流"入"頁面"中,然后輸出到媒介。
XSL-FO 輸出通常被嵌套在 <fo:block> 元素內(nèi),<fo:block> 嵌套于 <fo:flow> 元素內(nèi),<fo:flow> 嵌套于 <fo:page-sequence> 元素內(nèi):
<fo:flow flow-name="xsl-region-body">
<fo:block>
<!-- Output goes here -->
</fo:block>
</fo:flow>
</fo:page-sequence>
塊區(qū)域的屬性
塊是位于矩形框中的輸出序列:
This block of output will have a one millimeter border around it.
</fo:block>
由于塊區(qū)域是矩形框,所以可共享許多公共的區(qū)域?qū)傩裕?/p>
space before 和 space after
margin
border
padding

space before 和 space after 是塊與塊之間起分割作用的空白。
margin 是塊外側(cè)的空白區(qū)域。
border 是區(qū)域外部邊緣的矩形。其四個邊均可有不同的寬度。它也可被填充為不同的顏色和背景圖像。
padding 是位于 border 與 content 區(qū)域之間的區(qū)域。
content 區(qū)域可包含實際的內(nèi)容,比如文本、圖片、圖形等等。
塊邊距(Block Margin)
margin
margin-top
margin-bottom
margin-left
margin-right
塊邊框(Block Border)
邊框樣式屬性:
border-style
border-before-style
border-after-style
border-start-style
border-end-style
border-top-style(等同于 border-before)
border-bottom-style(等同于 border-after)
border-left-style(等同于 border-start)
border-right-style(等同于 border-end)
邊框顏色屬性:
border-color
border-before-color
border-after-color
border-start-color
border-end-color
border-top-color(等同于 border-before)
border-bottom-color(等同于 border-after)
border-left-color(等同于 border-start)
border-right-color(等同于 border-end)
邊框?qū)挾葘傩裕?/p>
border-width
border-before-width
border-after-width
border-start-width
border-end-width
border-top-width(等同于 border-before)
border-bottom-width(等同于 border-after)
border-left-width(等同于 border-start)
border-right-width(等同于 border-end)
塊填充(Block Padding)
padding
padding-before
padding-after
padding-start
padding-end
padding-top(等同于 padding-before)
padding-bottom(等同于 padding-after)
padding-left(等同于 padding-start)
padding-right(等同于 padding-end)
塊背景(Block Background)
background-color
background-image
background-repeat
background-attachment(scroll 或 fixed)
塊樣式屬性(Block Styling Attributes)
塊是可被單獨樣式化的輸出序列:
This block of output will be written in a 12pt sans-serif font.
</fo:block>
字體屬性:
font-family
font-weight
font-style
font-size
font-variant
文本屬性:
text-align
text-align-last
text-indent
start-indent
end-indent
wrap-option(定義自動換行)
break-before(定義分頁符)
break-after(定義分頁符)
reference-orientation(定義 90" 增量的文字旋轉(zhuǎn))
實例
space-before="5mm" space-after="5mm">
PHP.CN
</fo:block>
<fo:block text-indent="5mm" font-family="verdana" font-size="12pt">
At php.cn you will find all the Web-building tutorials you
need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.
</fo:block>
結(jié)果:
PHP.CN At php.cn you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP. |
請看上面的實例,如果要生成一個擁有許多標(biāo)題和段落的文檔,那么將會需要非常多的代碼。
通常,XSL-FO 文檔不會像我們剛才所做的那樣對格式化信息和內(nèi)容進(jìn)行組合。
通過 XSLT 的些許幫助,我們就可以把格式化信息置入模板,然后編寫出更純凈的內(nèi)容。
您會在本教程后面的章節(jié)學(xué)習(xí)到如何使用 XSLT 模板來組合 XSL-FO。