XSL Formatting Objects Tutorial (一)

XSL-FO is an XML language designed for describing all visual aspects of pagination documents.

The well known HTML is another language for specifying formatting semantics, but is more usable for documents that are presented to screen, and less for materials created for printing, because it doesn't support pagination elements like headers and footers, page size specifications, footnotes, etc.

XSL-FO is part of XSL language family:

XSLT - (XSL Transformations) a language for transfoming XML. (转换XML到XSL-FO)

XSL-FO - (XSL Formatting Objects) a language that can be used in XSLT for the purpose of "presenting" the XML. (XSL-FO使用fop可以直接转换为PDF)

 

XML + XSL Template  ---> XSL Transformation ---> XSL-FO ---> FOP ---> PDF

 

 

The XSL-FO language uses CSS(Cascading Style Sheets) to describe formatting attributes like fonts, colors, and borders, fo from this point of view, it should be easy to learn by HTML developers.This Manual

will help you understand the language and accomplish more complicated tasks.

Here is the traditional Hello World, XSL-FO style: 

<?xml version="1.0" encoding="UTF-8"?>

<!-- 引入dtd,提供提示功能 -->
<!DOCTYPE xsl-fo SYSTEM "fo.dtd"> 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="LetterPage" page-width="6.5in" page-height="2in">
			<fo:region-body region-name="PageBody" margin="0.2in"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	
	<fo:page-sequence master-reference="LetterPage">
		<fo:flow flow-name="PageBody" font-family="Microsoft YaHei" font-size="24pt">
			<fo:block>Hello XSL-FO!</fo:block>
		</fo:flow>
	</fo:page-sequence>
</fo:root>

猜你喜欢

转载自just2learn.iteye.com/blog/2039224
xsl