标题: XSL对象格式使用指南(三)
问天
元帅
Rank: 1


元帅勋章 终身成就勋章
UID 11493
精华 187
积分 34199
帖子 33353
威望 91
金币 13148
热心 2617
阅读权限 100
注册 2006-4-7
状态 离线
XSL对象格式使用指南(三)

在前两篇中我们已经讨论了怎样处理封面页和内容页,现在我们准备把以下内容放入这西班牙评论手册里。
   
   
  标题和段落属性由<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文件将得到:

网友 问天 签名 - 网友社区 请您回个帖。谢谢
PR查询 免费域名 免费空间
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-7 13:00
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP