XSL對象格式使用指南(三)

來源:互聯網
上載者:User
對象

 

在前兩篇中我們已經討論了怎樣處理封面頁和內容頁,現在我們準備把以下內容放入這西班牙評論手冊裡。
  
  
  標題和段落屬性由<fo:block> 元素控制,粗體和帶底線的詞語由<fo:inline>元素控制。現在開始描述第一個標題:
  <fo:block
  
  font-size="14pt" font-family="sans-serif"
  font-weight="bold" color="green"
  space-before="6pt" space-after="6pt">
  Introduction
  
  <fo:block>
  
  
  
  space-before屬性和space-after屬性是儲存地區中屬性設定值中的兩種。這些屬性和層疊樣式表CSS相類似
  字型屬性
  font-family,font-weight,font-style (斜體),font-size,font-stretch,font-variant
  背景屬性
  background-color,background-image,background-repeat,background-attachment (捲動或固定)
  邊界屬性
  border-location-info:
  location可以為before,after,start,,end,,top,bottom,left或right
  info is 可以為字型,寬度或顏色
  填充屬性
  padding-location:`
  location is 可以為before,after,,start,end,top,bottom,left或right
  空白屬性
  margin-location:
  location可以為top,bottom,left或right
  文本排列屬性
  text-align和text-align-last (用作文本最後一行); 函數可以為start,end,left,right或center
  縮排屬性
  text-indent (第一行),start-indent,end-indent
  其他屬性
  wrap-option (沒有約束或有約束);widows和orphans (決定頁面的頂部或左部有多少行)break-after和break-before;reference-orientation (將本文旋轉90度)
  
  通過這些屬性,我們可以明確定位一個複雜的段落。定位使用 “複合資料型別”的標點符號可以使頁面的版面可以在不同的映像解析度下自動適應:
  <fo:block
  
  text-indent="1em"
  font-family="sans-serif" font-size="12pt"
  space-before.minimum="2pt"
  space-before.maximum="6pt"
  space-before.optimum="4pt"
  space-after.minimum="2pt"
  space-after.maximum="6pt"
  space-after.optimum="4pt">
  This handbook covers the major topics in Spanish, but is by no means complete.
  
  <fo:block>
  
  
  
  如果你的文檔有很多標題或段落時,你不需要將所有的文檔逐一格式化。有XSLT ,我們能用XSLT把文檔寫入HTML 或轉換成詳細的XSL:FO 譯本。以下是已經轉換好的HTML :
  <h3>Introduction</h3>
  <p>
  This handbook covers the major topics in Spanish, but is by no means complete.
  </p>
  <h3>Accents</h3>
  <p>
  When we pronounce English words, one syllable is usually
  emphasized (<b>stressed</b>, in linguistic terms).
  The stressed syllable is underlined in the following words: com<u>pu</u>ter,<u>lan</u>guage, de<u>vel</u>opment, suc<u>ceeds</u>. Spanish words also have a stressed syllable, and there are rules for determining which syllable carries the emphasis.
  </p>
  
  
  下邊是標題和段落的模板:
  <xsl:template match="h3">
  
  <fo:block font-size="14pt" font-family="sans-serif"
  font-weight="bold" color="green"
  space-before="6pt" space-after="6pt">
  <xsl:apply-templates/>
  </fo:block>
  
  </xsl:template>
  
  <xsl:template match="p">
  
  <fo:block
  text-indent="1em"
  font-family="sans-serif" font-size="12pt"
  space-before.minimum="2pt"
  space-before.maximum="6pt"
  space-before.optimum="4pt"
  space-after.minimum="2pt"
  space-after.maximum="6pt"
  space-after.optimum="4pt">
  <xsl:apply-templates/>
  </fo:block>
  
  </xsl:template>
  
  
  
  在這篇文章初始化時已經設定了模板並將<html>和 <body>標記了,我們在這時不用再重複,只需用瀏覽器檢查一下。
  這是文檔的樹結構。用<b> 和 <u> 標記了最後一個子接點。它們在行列中的控制代碼為<fo:inline>元素。
  <xsl:template match="b">
  
  <fo:inline font-weight="bold">
  <xsl:apply-templates/>
  </fo:inline>
  
  </xsl:template>
  
  <xsl:template match="u">
  
  <fo:inline text-decoration="underline">
  <xsl:apply-templates/>
  </fo:inline>
  
  </xsl:template>
  
  <xsl:template match="i">
  
  <fo:inline font-style="italic">
  <xsl:apply-templates/>
  </fo:inline>
  
  </xsl:template>
  
  
  
  當我們通過XSLT 和FOP建立HTML檔案將得到:
  
  
  
  
  
  



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.