posts - 431,  comments - 344,  trackbacks - 0
          在學(xué)習(xí)XSL-FO之前,你應(yīng)該已經(jīng)掌握了XMLXML命名空間的基本知識(shí)。

          1.什么是XSL-FO?

          XSL-FO 是用于將結(jié)果格式化成XML數(shù)據(jù)的語(yǔ)言,XSL-FO全稱為(Extensible Stylesheet Language Formatting Objects:擴(kuò)展格式化對(duì)象樣式表語(yǔ)言),XSL-FO W3C的推薦標(biāo)準(zhǔn),XSL-FO 現(xiàn)在通常被稱為XSL。

          XSL-FO 是用于格式化數(shù)據(jù)的

          XSL是一種基于XML的標(biāo)記語(yǔ)言,它對(duì)輸出到屏幕、紙張或其它媒體上的XML數(shù)據(jù)的格式化作了具體的描述。

          XSL-FO現(xiàn)在通常叫做XSL

          樣式化包括信息的轉(zhuǎn)換格式化。當(dāng)萬(wàn)維網(wǎng)聯(lián)盟(W3C)做出第一份XSL工作草案時(shí),它包括了XML文檔的轉(zhuǎn)換和格式化的語(yǔ)法。后來(lái),W3CXSL工作組把原草案分成了以下幾塊參考標(biāo)準(zhǔn):

          l         XSLT,用于轉(zhuǎn)換XML文檔的語(yǔ)言

          l         XSL XSL-FO,用于格式化XML文檔的語(yǔ)言

          l         XPath,用于將XML文檔中的元素和屬性進(jìn)行定位的語(yǔ)言

          該教程剩下的部分是關(guān)于格式化XML文檔的語(yǔ)言的:XSL-FO,也稱為XSL。

          XSL-FO是一個(gè)網(wǎng)絡(luò)標(biāo)準(zhǔn)

          20011015XSL-FO已經(jīng)成為了W3C的推薦標(biāo)準(zhǔn)。它通常被稱為XSL

          2XSL-FO文檔

          XSL-FO文檔是包含輸出信息的XML文件。它們包含了與輸出的布局和輸出的內(nèi)容相關(guān)的信息。XSL-FO文檔以擴(kuò)展名“a .fo” “a .fob” 的文件保存在文件里。XSL-FO文檔也通常以“an .xml” 擴(kuò)展名來(lái)保存。因?yàn)檫@樣做可以使它們能更容易被XML編輯器訪問。

          XSL-FO文檔結(jié)構(gòu)

          <?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="A4">
              <!-- Page template goes here -->
           </fo:simple-page-master>
          </fo:layout-master-set>

          <fo:page-sequence master-reference="A4">
           <!-- Page content goes here -->
          </fo:page-sequence>

          </fo:root>

          結(jié)構(gòu)說明

          XSL-FO 文檔是XML文檔,所以必須在文檔的起始處包含一份XML聲明:

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

          <fo:root> 元素是XSL-FO文檔的根元素。根元素也給XSL-FO聲明了命名空間:

          <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                 <!-- The full XSL-FO document goes here -->
          </fo:root>

          <fo:layout-master-set> 元素包含了一個(gè)或多個(gè)頁(yè)面模板:

          <fo:layout-master-set>
                 <!-- All page templates go here -->
          </fo:layout-master-set>

          每個(gè)<fo:simple-page-master>元素包含著一個(gè)單獨(dú)的頁(yè)面模板。每個(gè)模板都包含一個(gè)獨(dú)立的名稱:

          <fo:simple-page-master master-name="A4">
                 <!-- One page template goes here -->
          </fo:simple-page-master>

          一個(gè)或多個(gè)<fo:page-sequence>元素描述了頁(yè)面內(nèi)容。Master-reference 屬性指的是同名的“simple-page-master” 模板。

          <fo:page-sequence master-reference="A4">
                 <!-- Page content goes here -->
          </fo:page-sequence>

          注意:事實(shí)上,master-reference = "A4" 并未真正地描述預(yù)定義頁(yè)面格式。它只是一個(gè)名稱而已。你可以隨意命名,如:"MyPage""MyTemplate" 等等這樣的名稱。

          3XSL-FO 區(qū)域

          XSL格式化模型定義了大量的矩形域(塊狀區(qū))來(lái)顯示結(jié)果。所有的結(jié)果(文本、圖片,等等)都會(huì)被格式化以后放入這些區(qū)域里,并且,它將會(huì)在目標(biāo)媒體上顯示或打印出來(lái)。讓我們進(jìn)一步看看下面的區(qū)域:

          l         Pages  頁(yè)面

          l         Regions  區(qū)域

          l         Block areas  塊狀區(qū)域

          l         Line areas  行區(qū)域

          l         Inline areas  行內(nèi)區(qū)域

          XSL-FO 頁(yè)面

          XSL-FO 結(jié)果被格式化成頁(yè)面形式。打印出來(lái)的結(jié)果通常會(huì)被寫進(jìn)很多獨(dú)立的頁(yè)面。瀏覽器的輸出的結(jié)果通常會(huì)顯示長(zhǎng)長(zhǎng)的一頁(yè)。XSL-FO頁(yè)面包含區(qū)域。

          XSL-FO 區(qū)域

          每張XSL-FO頁(yè)面都包含大量的區(qū)域。

          l         region-body   區(qū)域 主體(頁(yè)面的主體)

          l         region-before   區(qū)域頭部(頁(yè)面頁(yè)首)

          l         region-after  區(qū)域尾部(頁(yè)面的頁(yè)腳)

          l         region-start  區(qū)域左端(左工具條)

          l         region-end  區(qū)域右端(右工具條)

          XSL-FO 區(qū)域包含塊狀區(qū)域。

          XSL-FO 塊狀區(qū)域

          XSL-FO 塊狀區(qū)域定義了小塊狀元素(通常是以新的一行作為起始的元素),例如圖表、表格和列表。XSL-FO 塊狀區(qū)域可以包含其它的塊狀區(qū)域,但是大多數(shù)情況下,它們通常包含行區(qū)域。

          XSL-FO 行區(qū)域

          XSL-FO 行區(qū)域定義了塊狀區(qū)域內(nèi)部的文本行。XSL-FO 行區(qū)域包含行內(nèi)區(qū)域。

          XSL-FO Inline 行內(nèi)區(qū)域

          XSL-FO 行內(nèi)區(qū)域定義了行內(nèi)的文本內(nèi)容(段首粗體圓點(diǎn)、單字符、圖形,等等)。

          4XSL-FO 輸出

          XSL-FO <fo:flow> 元素中定義輸出結(jié)果。

          XSL-FO 頁(yè)面、流程和區(qū)域

          “塊狀區(qū)域”的內(nèi)容首先進(jìn)入“頁(yè)面”,然后再由指定的媒體輸出。XSL-FO 的輸出結(jié)果通常被嵌套在<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>

          XSL-FO 案例

          下面列舉一個(gè)關(guān)于XSL-FO的實(shí)際案例:

          <?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="A4">
           </fo:simple-page-master>
          </fo:layout-master-set>

          <fo:page-sequence master-reference="A4">
           <fo:flow flow-name="xsl-region-body">
              <fo:block>Hello w3pop.com</fo:block>
           </fo:flow>
          </fo:page-sequence>

          </fo:root>

          上述代碼應(yīng)該輸出下述結(jié)果:

          Hello w3pop.com

          5XSL-FO 流程

          XSL-FO 將被來(lái)自<fo:flow>元素中的數(shù)據(jù)所填充。XSL-FO 使用<fo:page-sequence>元素來(lái)定義結(jié)果頁(yè)面。每個(gè)結(jié)果頁(yè)面都包含了定義頁(yè)面布局的頁(yè)面主體元素。每個(gè)結(jié)果頁(yè)面都包含一個(gè)定義輸出結(jié)果<fo:flow>元素。每個(gè)結(jié)果頁(yè)面都會(huì)按照一定順序打?。ɑ蝻@示)。

          XSL-FO 流程

          XSL-FO 將被來(lái)自<fo:flow>元素中的內(nèi)容所填充。<fo:flow> 元素包含了需要在頁(yè)面上打印的所有元素。當(dāng)頁(yè)面被印滿時(shí),相同的頁(yè)面主體元素會(huì)被反復(fù)地使用,直到所有的文本內(nèi)容都被打印出來(lái)為止。

          流程流向哪里?

          <fo:flow> 元素包含“flow-name(流程名稱)屬性。“flow-name(流程名稱)的屬性值定義了<fo:flow>元素的內(nèi)容將流向何處。所有合法值如下:

          l         xsl-region-body :流向區(qū)域主體

          l         xsl-region-before :流向區(qū)域最上端

          l         xsl-region-after :流向區(qū)域最下端

          l         xsl-region-start :流向區(qū)域左端

          l         xsl-region-end :流向區(qū)域右端

          6XSL-FO 頁(yè)面

          XSL-FO 使用名為 “Page Masters [ 頁(yè)面主體 ] ” 的頁(yè)面模板來(lái)定義頁(yè)面的布局。

          XSL-FO 頁(yè)面模板
          XSL-FO 使用名為“Page Masters [ 頁(yè)面主體 ] ” 的頁(yè)面模板來(lái)定義頁(yè)面的布局。每塊模板必須包含一個(gè)獨(dú)立的名稱:

          <fo:simple-page-master master-name="intro">
           <fo:region-body margin="5in" />
          </fo:simple-page-master>

          <fo:simple-page-master master-name="left">
           <fo:region-body margin-left="2in" margin-right="3in" />
          </fo:simple-page-master>

          <fo:simple-page-master master-name="right">
           <fo:region-body margin-left="3in" margin-right="2in" />
          </fo:simple-page-master>

          在上述案例中,三個(gè)<fo:simple-page-master>元素,定義了三塊不同的模板。每塊模板都包含不同的名稱。第一塊模板稱為“intro”,它是用于介紹頁(yè)面的模板。第二和第三塊模板稱作"left" "right"。它們是用于定義奇數(shù)頁(yè)面和偶數(shù)頁(yè)面。

          XSL-FO 頁(yè)面大小

          XSL-FO 使用下述屬性來(lái)定義頁(yè)面的尺寸:

          a)         page-width 定義了頁(yè)面的寬度

          b)        page-height 定義了頁(yè)面的高度

          XSL-FO 頁(yè)面邊界

          XSL-FO 用下述屬性來(lái)定義頁(yè)面邊界:

          a)         margin-top 定義頂邊界

          b)        margin-bottom 定義底邊界

          c)        margin-left 定義左邊界

          d)        margin-right 定義右邊界

          e)         margin 定義所有四個(gè)邊界

          XSL-FO 頁(yè)面區(qū)域

          XSL-FO 使用以下元素來(lái)定義頁(yè)面的區(qū)域:

          a)         region-body 定義主體區(qū)域

          b)        region-before 定義頂端區(qū)域(頁(yè)眉)

          c)        region-after 定義底端區(qū)域(頁(yè)腳)

          d)        region-start 定義左端區(qū)域(左端工具條)

          e)         region-end 定義右端區(qū)域(右端工具條)

          前端區(qū)域(region-before),后端區(qū)域(region-after),起始區(qū)域(region-start),終止區(qū)域(region-end)是主體區(qū)域的一部分。為了避免文本在主體區(qū)域內(nèi)溢出,主體區(qū)域的邊界尺寸至少要和上述這些區(qū)域一樣。

          Margin Top

          M
          a
          r
          g
          i
          n

          L
          e
          f
          t

          REGION BEFORE

          R
          E
          G
          I
          O
          N

          S
          T
          A
          R
          T

           

           

           

           

           

          REGION BODY

           

           

           

           

           

           

          R
          E
          G
          I
          O
          N

          E
          N
          D

          REGION AFTER

          M
          a
          r
          g
          i
          n

          R
          i
          g
          h
          t

          Margin Bottom

          XSL-FO例子

          下面列舉了一份XSL-FO文檔的部分內(nèi)容:

          <fo:simple-page-master master-name="A4"
           page-width="297mm" page-height="210mm"
           margin-top="1cm"   margin-bottom="1cm"
           margin-left="1cm" margin-right="1cm">
           <fo:region-body   margin="3cm"/>
           <fo:region-before extent="2cm"/>
           <fo:region-after extent="2cm"/>
           <fo:region-start extent="2cm"/>
           <fo:region-end    extent="2cm"/>
          </fo:simple-page-master>

          上述代碼定義了名稱為"A4"“Simple Page Master”模板。這張頁(yè)面寬297毫米,高210毫米。頁(yè)面的上下左右邊界都是1厘米。主體部分的四條邊上包含了寬為3厘米的邊界。主體的上下左右部分都是2厘米。在上述案例中,主體寬度 = 頁(yè)面自身寬度 - 左右邊界寬度 - 區(qū)域主體邊界寬度,具體如下:

                 297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm.

          注意:區(qū)域(左端區(qū)域和右端區(qū)域)并不在計(jì)算范圍之內(nèi)。如同前面所說的那樣,這些區(qū)域只是主體的一部分。

          7XSL-FO 塊狀區(qū)域

          XSL-FO 結(jié)果將輸入塊狀區(qū)域。

          XSL-FO 頁(yè)面、流程 以及 塊狀區(qū)域

          “塊狀區(qū)域”的內(nèi)容首先進(jìn)入“頁(yè)面”,然后再由指定的媒體輸出。XSL-FO 的輸出結(jié)果通常被嵌套在<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 區(qū)域?qū)傩?/span>
          塊狀區(qū)域包含矩形框內(nèi)的結(jié)果序列:

          <fo:block
           border-width="1mm">
          This block of output will have a one millimeter border around it.
          </fo:block>

          因?yàn)閴K狀區(qū)域的是矩形框,它們共享很多共同的區(qū)域性質(zhì):

          l         space before and space after 最上端邊界和最下端邊界

          l         margin 邊界

          l         border 邊框

          l         padding 補(bǔ)白

          Space before [頂端空間]space after [底端空間]是用來(lái)分隔其它塊狀區(qū)域的空白空間。margin [邊界]是塊狀區(qū)域外部的空白區(qū)域。border [邊框]是矩形框的四條邊;它們可以有不同的寬度;它們也可以填充不同的顏色和背景圖片,padding [補(bǔ)白]是位于邊框和內(nèi)容區(qū)域之間的地方。content [內(nèi)容]區(qū)域包含了類似于文本、圖片、圖表等實(shí)際存在的內(nèi)容。

          塊狀區(qū)域邊界

          l         margin四邊邊界

          l         margin-top頂部邊界

          l         margin-bottom底部邊界

          l         margin-left左邊界

          l         margin-right右邊界

          塊狀區(qū)域邊框

          邊框樣式屬性:

          l         border-style邊框樣式

          l         border-before-style頂端邊框樣式

          l         border-after-style底端邊框樣式

          l         border-start-style左端邊框樣式

          l         border-end-style右端邊框樣式

          l         border-top-style (same as border-before) 頂端邊框樣式(和 border-before 相同)

          l         border-bottom-style (same as border-after) 底端邊框樣式(邊 border-after 相同)

          l         border-left-style (same as border-start) 左端邊框樣式(和 border-start 相同)

          l         border-right-style (same as border-end) 右端邊框樣式(和 border-end 相同)

          邊框顏色屬性:

          l         border-color邊框顏色

          l         border-before-color頂端邊框顏色

          l         border-after-color底端邊框顏色

          l         border-start-color左端邊框顏色

          l         border-end-color右端邊框顏色

          l         border-top-color (same as border-before) 頂端邊框顏色(和 border-before 相同)

          l         border-bottom-color (same as border-after) 底端邊框顏色(和 border-after 相同)

          l         border-left-color (same as border-start) 左端邊框顏色(和 border-start 相同)

          l         border-right-color (same as border-end) 右端邊框顏色(和 border-end 相同)

          邊框?qū)挾葘傩裕?/span>

          l         border-width邊框?qū)挾?/span>

          l         border-before-width頂端邊框?qū)挾?/span>

          l         border-after-width底端邊框?qū)挾?/span>

          l         border-start-width左端邊框?qū)挾?/span>

          l         border-end-width右端邊框?qū)挾?/span>

          l         border-top-width (same as border-before) 頂端邊框?qū)挾龋ê?/span> border-before 相同)

          l         border-bottom-width (same as border-after) 底端邊框?qū)挾龋ê?/span> border-after 相同)

          l         border-left-width (same as border-start) 左端邊框?qū)挾龋ê?/span> border-start 相同)

          l         border-right-width (same as border-end) 右端邊框?qū)挾龋ê?/span> border-end 相同)

          塊狀區(qū)域補(bǔ)白:

          l         padding補(bǔ)白

          l         padding-before頂端補(bǔ)白

          l         padding-after底端補(bǔ)白

          l         padding-start左端補(bǔ)白

          l         padding-end右端補(bǔ)白

          l         padding-top (same as padding-before) 頂端補(bǔ)白(和 padding-before 相同)

          l         padding-bottom (same as padding-after) 底端補(bǔ)白(和 padding-after 相同)

          l         padding-left (same as padding-start) 左端補(bǔ)白(和 padding-start 相同)

          l         padding-right (same as padding-end) 右端補(bǔ)白(和 padding-end 相同)

          塊狀區(qū)域背景

          l         background-color背景顏色

          l         background-image背景圖形

          l         background-repeat背景重復(fù)

          l         background-attachment (scroll or fixed) 背景滾動(dòng)設(shè)置(scroll:隨頁(yè)面滾動(dòng)而滾動(dòng);fixed:不隨頁(yè)面滾動(dòng)而滾動(dòng))

          塊狀區(qū)域樣式屬性
          塊狀區(qū)域包含了可以單獨(dú)定義樣式的結(jié)果序列:

          <fo:block
           font-size="12pt"
           font-family="sans-serif">
          This block of output will be written in a 12pt sans-serif font.
          </fo:block>

          字體屬性:

          l         font-family字體

          l         font-weight字體粗細(xì)

          l         font-style字形

          l         font-size字體尺寸

          l         font-variant字體變量

          文本屬性:

          l         text-align文本排列

          l         text-align-last文本排列持續(xù)

          l         text-indent文本縮進(jìn)

          l         start-indent頂端縮進(jìn)

          l         end-indent底端縮進(jìn)

          l         wrap-option (defines word wrap) 嵌套選項(xiàng)(定義自動(dòng)換行)

          l         break-before (defines page breaks) 頁(yè)面左端換行(定義頁(yè)面換行)

          l         break-after (defines page breaks) 頁(yè)面右端換行(定義頁(yè)面換行)

          l         reference-orientation (defines text rotation in 90" increments) 參考定位(定義90度內(nèi)的文本旋轉(zhuǎn))

          舉例

          <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 w3pop.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:
          結(jié)果

          W3Schools

             At w3pop.com you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.

          從上述案例中,你會(huì)發(fā)現(xiàn),要?jiǎng)?chuàng)建一份包含多個(gè)標(biāo)題和段落的文檔需要使用大量的代碼。一般情況下,XSL-FO文檔不需要將格式化信息和內(nèi)容結(jié)合起來(lái)。只需要使用XSLT的一小部分功能,我們就可以把格式化信息放入模板中,書寫一份整潔的內(nèi)容了。當(dāng)你學(xué)完這份教程之后,你就會(huì)掌握更多關(guān)于把XSL-FOXSLT模板結(jié)合起來(lái)使用的方法。

          8XSL-FO 列表

          XSL-FO用列表塊區(qū)定義列表

          XSL-FO列表區(qū)

          用于創(chuàng)建列表的XSL-FO對(duì)象有以下四個(gè):

          l         fo:list-block (含有整個(gè)列表)

          l         fo:list-item (含有列表里的每一項(xiàng))

          l        fo:list-item-label (含有列表項(xiàng)的標(biāo)簽,典型的例子如:一個(gè)<fo:block>元素含有一個(gè)數(shù)字,字符,等等.)

          l         fo:list-item-body (含有列表項(xiàng)的內(nèi)容和主體,典型的例子如:一個(gè)或多個(gè)<fo:block>對(duì)象)

          一份XSL-FO列表的例子:

          <fo:list-block>

          <fo:list-item>
           <fo:list-item-label>
             <fo:block>*</fo:block>
           </fo:list-item-label>
           <fo:list-item-body>
             <fo:block>Volvo</fo:block>
           </fo:list-item-body>
          </fo:list-item>

          <fo:list-item>

           <fo:list-item-label>
             <fo:block>*</fo:block>
           </fo:list-item-label>
           <fo:list-item-body>
             <fo:block>Saab</fo:block>
           </fo:list-item-body>
          </fo:list-item>

          </fo:list-block>

          The output from this code would be:
          這份代碼應(yīng)該輸出如下結(jié)果:

           * Volvo
           * Saab

          9XSL-FO 表格

          XSL-FO 使用<fo:table-and-caption>元素定義表格。

          XSL-FO 表格

          XSL-FO 的表格模式和HTML表格模式相差不大。下面列舉9個(gè)可以用于創(chuàng)建表格的XSL-FO對(duì)象:

          l         fo:table-and-caption

          l         fo:table

          l         fo:table-caption

          l         fo:table-column

          l         fo:table-header

          l         fo:table-footer

          l         fo:table-body

          l         fo:table-row

          l         fo:table-cell

          XSL-FO使用<fo:table-and-caption>元素來(lái)定義一張表格。它包含了一個(gè)<fo:table>元素和一個(gè)可選擇的<fo:caption>元素。<fo:table>元素包含了幾個(gè)可選擇的<fo:table-column>元素,一個(gè)可選擇的<fo:table-footer>元素。這些元素都包含一個(gè)或多個(gè)的<fo:table-row>元素以及一個(gè)或多個(gè)的<fo:table-cell>元素:

          <fo:table-and-caption>
          <fo:table>
          <fo:table-column column-width="25mm"/>
          <fo:table-column column-width="25mm"/>
          <fo:table-header>
           <fo:table-row>
              <fo:table-cell>
                <fo:block font-weight="bold">Car</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block font-weight="bold">Price</fo:block>
              </fo:table-cell>
           </fo:table-row>
          </fo:table-header>
          <fo:table-body>
           <fo:table-row>
              <fo:table-cell>
                <fo:block>Volvo</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>$50000</fo:block>
              </fo:table-cell>
           </fo:table-row>
           <fo:table-row>
              <fo:table-cell>
                <fo:block>SAAB</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>$48000</fo:block>
              </fo:table-cell>
           </fo:table-row>
          </fo:table-body>
          </fo:table>
          </fo:table-and-caption>

          The output from this code would something like this:
          上述代碼將輸出如下結(jié)果:

          Car

          Price

          Volvo

          $50000

          SAAB

          $48000

          10XSL-FO XSLT

          XSL-FO XSLT 可以進(jìn)行功能互補(bǔ)。

          還記得下面這個(gè)案例嗎?

          <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 w3pop.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:
          結(jié)果

          W3Schools

             At w3pop.com you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.

          XSLT中得到一些幫助
          從文檔中刪除XSL-FO信息的方法:

          <header>
          W3Schools
          </header>

          <paragraph>
          At W3pop.com you will find all the Web-building tutorials you
          need, from basic HTML and XHTML to advanced XML, XSL, Multimedia
          and WAP.
          </paragraph>

          Add an XSLT transformation:
          添加一條 XSLT 轉(zhuǎn)換信息的方法:

          <xsl:template match="header">
          <fo:block
              font-size="14pt" font-family="verdana" color="red"
              space-before="5mm" space-after="5mm">
              <xsl:apply-templates/>
          </fo:block>
          </xsl:template>
          <xsl:template match="paragraph">
          <fo:block
              text-indent="5mm"
              font-family="verdana" font-size="12pt"
              space-before="5mm" space-after="5mm">

              <xsl:apply-templates/>
          </fo:block>
          </xsl:template>

          And the result will be the same:
          結(jié)果仍然相同:

          W3Schools

          At W3pop.com you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.

          11XSL-FO 軟件

          XSL-FO 需要格式化軟件來(lái)輸出結(jié)果。

          XSL-FO 處理器

          XSL-FO 處理器是用于格式化XML文檔輸出結(jié)果的軟件程序。大多數(shù)XSL-FO 處理器可以輸出PDF文檔,并進(jìn)行高質(zhì)量的打印。當(dāng)然,它還可以HTML等其它形式輸出。下面的部分介紹一些知名的XSL-FO處理器。

          1)        XSL FormatterXSL Formatter 是一種用于格式化XML文檔的軟件,從而可以打印輸出高質(zhì)量的PDF文件。在2002年的一月,全球市場(chǎng)上推出了相同產(chǎn)品的V2版本。在歐洲舉辦的XML 2002, XML 2003 峰會(huì)上,XSL Formatter被公認(rèn)為品質(zhì)最佳的產(chǎn)品。在擁有4XSL-FO軟件開發(fā)經(jīng)驗(yàn)的基礎(chǔ)之上,, Antenna House又從頭開發(fā)全新的Formatter。這種Formatter將增加一些更顯著實(shí)用的功能,并為將來(lái)的繼續(xù)發(fā)展提供了堅(jiān)實(shí)的基礎(chǔ)。

          2)        XincXinc Lunasil 公司推出的XSL-FO處理器。Xinc的特點(diǎn)是:運(yùn)行速度快,多路處理,并有記憶效果。包含擺動(dòng)裝置的XSL-FO閱讀器可以瀏覽和打印XSL-FO文件,只需要點(diǎn)擊鼠標(biāo)就可以操做PDF文件;通過XincJava APIJava應(yīng)用程序接口),Xinc可以作為服務(wù)器組件使用;通過XincCOM(串行通訊端口)分界面,它也可在Microsoft服務(wù)器環(huán)境下使用。它的新特點(diǎn)如下:連字符號(hào)連接、基礎(chǔ)連接、PDF輸出、內(nèi)存 / 速度最優(yōu)化和簡(jiǎn)單的COM界面。

          3)        ScripturaInventive Designers Scriptura 是基于XSLT XSL-FO 跨平臺(tái)文檔設(shè)計(jì)器和問題處理器。Scriptura 包含一個(gè) WYSIWYG(即見及所得)的工具和引擎。在該引擎中使用的 XSL-FO formatter 已經(jīng)不再以 Apache FOP 為基礎(chǔ)了,而是設(shè)計(jì)者們重新開始書寫。這個(gè)版本的新特點(diǎn)是:支持圓點(diǎn)、編號(hào)列表、“break-before [ 頂部換行 ]” “break-after [ 底部換行 ]” 特性;擴(kuò)展的條形碼選項(xiàng)、改進(jìn)的數(shù)字、貨幣格式。免費(fèi)的體驗(yàn)版本可以通過下載獲取。

          XSL格式化對(duì)象參考資料

          將具體描述轉(zhuǎn)化為表達(dá)式的過程稱為格式化:

          Object
          對(duì)象

          Description
          描述

          basic-link

          Represents the start resource of a link
          頂端資源鏈接

          bidi-override

          Overrides the default Unicode BIDI direction
          忽略默認(rèn)統(tǒng)一字符編碼標(biāo)準(zhǔn)BIDI的用法

          block

          Defines a block of output (e.g. paragraphs and titles)
          定義輸出組件(比如:段落、標(biāo)題)

          block-container

          Defines a block-level reference-area
          定義一個(gè)block層次等級(jí)參考面

          character

          Specifies a character that will be mapped to a glyph for presentation
          指定將被映射為字形表達(dá)式的字符

          color-profile

          Defines a color-profile for a stylesheet
          定義樣式表的輪廓顏色

          conditional-page-master-reference

          Specifies a page-master to be used when the conditions defined are true
          當(dāng)條件為true真時(shí),允許使用page-master [ 頁(yè)面主體 ]

          declarations

          Groups global declarations for a stylesheet
          群組一個(gè)通用的樣式

          external-graphic

          Used for a graphic where the graphics data resides outside of the XML result tree
          用于圖形數(shù)據(jù)位于XML結(jié)果樹的外部的圖形

          float

          Typically used to position an image in a separate area at the beginning of a page OR to position an image to one side, with the content flowing along-side of the image
          常用于在頁(yè)面起始處的一個(gè)單獨(dú)區(qū)域里指定一個(gè)圖形的位置,或者將內(nèi)容浮動(dòng)于圖形的周圍

          flow

          Contains all elements to be printed to a page
          包含所有要打印在頁(yè)面上的元素

          footnote

          Defines a footnote within the region-body of a page
          在頁(yè)面區(qū)域主體上定義腳注

          footnote-body

          Defines the content of the footnote
          定義腳注內(nèi)容

          initial-property-set

          Formats the first line of an <fo:block>
          格式化<fo:block>元素的第一行

          inline

          Formats a part of a text with a background or enclosing it in a border
          通過背景屬性或?qū)⑵淝度胍粋€(gè)邊框來(lái)定義文本的一部分格式

          inline-container

          Defines an inline reference-area
          定義行內(nèi)參數(shù)區(qū)域

          instream-foreign-object

          Used for inline graphics or for "generic" objects where the object's data resides as descendants of <fo:instream-foreign-object>
          用于行內(nèi)圖形或類對(duì)象。在其中,對(duì)象的數(shù)據(jù)以<fo:instream-foreign-object>的孫類元素形式存在

          layout-master-set

          Holds all masters used in a document
          保留文檔中所有使用的master[ 主體 ]

          leader

          Used to generate "." to separate titles from page numbers in table of contents, or to create input fields in forms, or to create horizontal rules
          通過定義 “.” 為分割頁(yè)面中的標(biāo)題,或者建立一個(gè)表單輸入字段或一個(gè)平行法則

          list-block

          Defines a list
          定義一張列表

          list-item

          Contains each item in the list
          包含列表的每個(gè)項(xiàng)

          list-item-body

          Contains the content/body of the list-item
          包含列表項(xiàng)的內(nèi)容 / 主體

          list-item-label

          Contains the label for the list-item (typically a number, character, etc.)
          包含列表項(xiàng)的標(biāo)簽(一般是一個(gè)數(shù)字、字符,等等)

          marker

          Used with <fo:retrieve-marker> to create running headers or footers
          使用<fo:retrieve-marker>來(lái)創(chuàng)建運(yùn)行標(biāo)題或運(yùn)行頁(yè)腳

          multi-case

          Contains (within an <fo:multi-switch>) each alternative sub-tree of XSL-FO objects. The parent <fo:multi-switch> will choose which alternative to show and hide the rest
          在<fo:multi-switch>中,包含了每一個(gè)可用于替代XSL-FO對(duì)象的子樹的對(duì)象。父級(jí) <fo:multi-switch> 會(huì)選擇其中一個(gè)來(lái)決定 “顯示或隱藏” 剩余的部分。

          multi-properties

          Used to switch between two or more property-sets
          用于在兩個(gè)或更多的屬性集之間進(jìn)行轉(zhuǎn)換

          multi-property-set

          Specifies an alternative property-set that will be applied depending on the state of the user agent
          根據(jù)用戶的代理狀態(tài),指定一個(gè)應(yīng)用屬性集的替代元素

          multi-switch

          Holds one or more <fo:multi-case> objects and controls the switching between them (activated by <fo:multi-toggle>)
          保留一個(gè)或多個(gè)<fo:multi-case>對(duì)象,控制它們(由 <fo:multi-toggle> 觸發(fā))彼此之間的轉(zhuǎn)換

          multi-toggle

          Used to switch to another <fo:multi-case>
          用于轉(zhuǎn)換成另一個(gè) <fo:multi-toggle>元素

          page-number

          Represents the current page-number
          指示當(dāng)前頁(yè)碼

          page-number-citation

          References the page-number for the page that contains the first normal area returned by the cited object
          為包含由site對(duì)象所返回的第一標(biāo)準(zhǔn)區(qū)域指定頁(yè)碼

          page-sequence

          A container for page output elements. There will be one <fo:page-sequence> object for each page layout
          指定一個(gè)頁(yè)面結(jié)果元素的容器。這里,<fo:page-sequence>對(duì)象適用于所有的頁(yè)面布局

          page-sequence-master

          Specifies which simple-page-masters are to be used and in which order
          指定使用的“simple-page-masters [簡(jiǎn)單頁(yè)面主體] ” 以及使用順序

          region-after

          Defines a page footer
          定義頁(yè)腳

          region-before

          Defines a page header
          定義頁(yè)眉

          region-body

          Defines a page body
          定義頁(yè)面主體

          region-end

          Defines the right sidebar of a page
          定義頁(yè)面右工具條

          region-start

          Defines the left sidebar of a page
          定義頁(yè)面左工具條

          repeatable-page-master-alternatives

          Specifies repetition of a set of simple-page-masters
          指定一組 “simple-page-masters” 循環(huán)

          repeatable-page-master-reference

          Specifies repetition of a single simple-page-master
          指定單個(gè) “simple-page-masters” 循環(huán)

          retrieve-marker

          Used with <fo:marker> to create running headers or footers
          使用 <fo:marker> 創(chuàng)建運(yùn)行的標(biāo)題與頁(yè)腳

          root

          The root (top) node for XSL-FO documents
          指定XSL-FO文檔的根目錄節(jié)點(diǎn)

          simple-page-master

          Defines the size and shape of a page
          定義頁(yè)面的尺寸與形狀

          single-page-master-reference

          Specifies a page-master to be used at a given point in the sequence of pages
          在一個(gè)頁(yè)面序列的給定點(diǎn)中指定 page-master [ 頁(yè)面主體 ]

          static-content

          Contains static content (e.g. headers and footers) that will be repeated on many pages
          指定在多個(gè)頁(yè)面中重復(fù)使用或出現(xiàn)的靜態(tài)內(nèi)容(如:頁(yè)眉和頁(yè)腳)

          table

          Formats the tabular material of a table
          格式化表格的列表材料

          table-and-caption

          Formats a table and its caption
          格式化表格及其標(biāo)題

          table-body

          Container for table rows and table cells
          指定表格行和單元格的容器

          table-caption

          Contains the caption for a table
          指定表格標(biāo)題

          table-cell

          Defines a table cell
          定義一個(gè)單元格

          table-column

          Formats the columns of a table
          格式化表格列

          table-footer

          Defines a table footer
          定義表格頁(yè)腳

          table-header

          Defines a table header
          定義表格頁(yè)眉

          table-row

          Defines a table row
          定義表格行

          title

          Defines a title for a page-sequence
          定義頁(yè)面序列的標(biāo)題

          wrapper

          Specifies inherited properties for a group of XSL-FO objects
          指定XSL-FO對(duì)象組的繼承屬性

          posted on 2008-01-18 14:36 周銳 閱讀(1385) 評(píng)論(0)  編輯  收藏 所屬分類: HTMLXMLXSLT
          主站蜘蛛池模板: 山阳县| 吉安市| 贡觉县| 汪清县| 平塘县| 泸西县| 巴马| 康马县| 吉林省| 罗山县| 阜新市| 兰西县| 潜江市| 绥阳县| 定兴县| 赤峰市| 霍州市| 铁岭县| 达尔| 杂多县| 剑川县| 洞口县| 禹城市| 高青县| 库伦旗| 台东市| 那坡县| 信丰县| 双江| 荥阳市| 砚山县| 句容市| 保靖县| 嘉定区| 永善县| 石台县| 灵宝市| 罗甸县| 和静县| 上饶市| 汕尾市|