XSL-FO 与 XSLT

XSL-FO 与 XSLT 可彼此互助。


比如前面章节的例子

  1. <fo:block
  2. font-size="14pt" font-family="verdana" color="red"
  3. space-before="5mm" space-after="5mm">
  4. Cankaoshouce
  5. </fo:block>
  6. <fo:block
  7. text-indent="5mm"
  8. font-family="verdana" font-size="12pt"
  9. space-before="5mm" space-after="5mm">
  10. At Cankaoshouce you will find all the Web-building tutorials you
  11. need, from basic HTML and XHTML to advanced XML, XSL, Multimedia
  12. and WAP.
  13. </fo:block>

来自 XSLT 的帮助

从文档移除 XSL-FO 信息:
  1. <header>
  2. Cankaoshouce
  3. </header>
  4. <paragraph>
  5. At Cankaoshouce you will find all the Web-building tutorials you
  6. need, from basic HTML and XHTML to advanced XML, XSL, Multimedia
  7. and WAP.
  8. </paragraph>
添加 XSLT 转换:
  1. <xsl:template match="header">
  2. <fo:block
  3. font-size="14pt" font-family="verdana" color="red"
  4. space-before="5mm" space-after="5mm">
  5. <xsl:apply-templates/>
  6. </fo:block>
  7. </xsl:template>
  8. <xsl:template match="paragraph">
  9. <fo:block
  10. text-indent="5mm"
  11. font-family="verdana" font-size="12pt"
  12. space-before="5mm" space-after="5mm">
  13. <xsl:apply-templates/>
  14. </fo:block>
  15. </xsl:template>

产生的结果是相同的。