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

此例来自有关 XSL-FO 块区域的那一节。

来自 XSLT 的帮助

从文档移除 XSL-FO 信息:

  1. <header>
  2. yousite
  3. </header>
  4.  
  5. <paragraph>
  6. At yousite you will find all the Web-building tutorials you
  7. need, from basic HTML and XHTML to advanced XML, XSL, Multimedia
  8. and WAP.
  9. </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.  
  9. <xsl:template match="paragraph">
  10. <fo:block
  11. text-indent="5mm"
  12. font-family="verdana" font-size="12pt"
  13. space-before="5mm" space-after="5mm">
  14. <xsl:apply-templates/>
  15. </fo:block>
  16. </xsl:template>