fo-rtf.xsl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. xmlns:exsl="http://exslt.org/common"
  5. xmlns:set="http://exslt.org/sets"
  6. exclude-result-prefixes="exsl set"
  7. version="1.0">
  8. <!-- ********************************************************************
  9. $Id: fo-rtf.xsl 6910 2007-06-28 23:23:30Z xmldoc $
  10. ********************************************************************
  11. This file is part of the DocBook XSL Stylesheet distribution.
  12. See ../README or http://docbook.sf.net/ for copyright
  13. copyright and other information.
  14. ******************************************************************** -->
  15. <!-- This module contains templates that match against FO nodes. It is used
  16. to post-process result tree fragments for some sorts of cleanup.
  17. These templates can only ever be fired by a processor that supports
  18. exslt:node-set(). -->
  19. <!-- ==================================================================== -->
  20. <!-- insert.fo.fnum mode templates insert a particular RTF at the beginning
  21. of the first paragraph in the primary RTF. In fact, they are inserting
  22. a footnote-number, so we tinker a few other things too, like spacing and
  23. font-sizes. -->
  24. <xsl:template match="/" mode="insert.fo.fnum">
  25. <xsl:param name="mark" select="'?'"/>
  26. <xsl:apply-templates mode="insert.fo.fnum">
  27. <xsl:with-param name="mark" select="$mark"/>
  28. </xsl:apply-templates>
  29. </xsl:template>
  30. <xsl:template match="*" mode="insert.fo.fnum">
  31. <xsl:param name="mark" select="'?'"/>
  32. <xsl:copy>
  33. <xsl:copy-of select="@*"/>
  34. <xsl:apply-templates mode="insert.fo.fnum">
  35. <xsl:with-param name="mark" select="$mark"/>
  36. </xsl:apply-templates>
  37. </xsl:copy>
  38. </xsl:template>
  39. <xsl:template match="fo:block" mode="insert.fo.fnum">
  40. <xsl:param name="mark" select="'?'"/>
  41. <xsl:copy>
  42. <xsl:for-each select="@*">
  43. <xsl:choose>
  44. <xsl:when test="starts-with(name(.), 'space-before')"/>
  45. <xsl:when test="starts-with(name(.), 'space-after')"/>
  46. <xsl:when test="starts-with(name(.), 'font-size')"/>
  47. <xsl:otherwise>
  48. <xsl:copy-of select="."/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:for-each>
  52. <xsl:if test="not(preceding::fo:block)">
  53. <xsl:copy-of select="$mark"/>
  54. </xsl:if>
  55. <xsl:apply-templates mode="insert.fo.fnum">
  56. <xsl:with-param name="mark" select="$mark"/>
  57. </xsl:apply-templates>
  58. </xsl:copy>
  59. </xsl:template>
  60. <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.fnum">
  61. <xsl:param name="mark" select="'?'"/>
  62. <xsl:copy/>
  63. </xsl:template>
  64. <!-- ==================================================================== -->
  65. <!-- insert.fo.block mode templates insert a particular RTF at the beginning
  66. of the first paragraph in the primary RTF. -->
  67. <xsl:template match="/" mode="insert.fo.block">
  68. <xsl:param name="mark" select="'?'"/>
  69. <xsl:apply-templates mode="insert.fo.block">
  70. <xsl:with-param name="mark" select="$mark"/>
  71. </xsl:apply-templates>
  72. </xsl:template>
  73. <xsl:template match="*" mode="insert.fo.block">
  74. <xsl:param name="mark" select="'?'"/>
  75. <xsl:copy>
  76. <xsl:copy-of select="@*"/>
  77. <xsl:apply-templates mode="insert.fo.block">
  78. <xsl:with-param name="mark" select="$mark"/>
  79. </xsl:apply-templates>
  80. </xsl:copy>
  81. </xsl:template>
  82. <xsl:template match="fo:block" mode="insert.fo.block">
  83. <xsl:param name="mark" select="'?'"/>
  84. <xsl:copy>
  85. <xsl:copy-of select="@*"/>
  86. <xsl:if test="not(preceding::fo:block)">
  87. <xsl:copy-of select="$mark"/>
  88. </xsl:if>
  89. <xsl:apply-templates mode="insert.fo.block">
  90. <xsl:with-param name="mark" select="$mark"/>
  91. </xsl:apply-templates>
  92. </xsl:copy>
  93. </xsl:template>
  94. <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.block">
  95. <xsl:param name="mark" select="'?'"/>
  96. <xsl:copy/>
  97. </xsl:template>
  98. <!-- ==================================================================== -->
  99. <!-- insert.fo.text mode templates insert a particular RTF at the beginning
  100. of the first text-node in the primary RTF. -->
  101. <xsl:template match="/" mode="insert.fo.text">
  102. <xsl:param name="mark" select="'?'"/>
  103. <xsl:apply-templates mode="insert.fo.text">
  104. <xsl:with-param name="mark" select="$mark"/>
  105. </xsl:apply-templates>
  106. </xsl:template>
  107. <xsl:template match="*" mode="insert.fo.text">
  108. <xsl:param name="mark" select="'?'"/>
  109. <xsl:copy>
  110. <xsl:copy-of select="@*"/>
  111. <xsl:apply-templates mode="insert.fo.text">
  112. <xsl:with-param name="mark" select="$mark"/>
  113. </xsl:apply-templates>
  114. </xsl:copy>
  115. </xsl:template>
  116. <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.text">
  117. <xsl:param name="mark" select="'?'"/>
  118. <xsl:if test="not(preceding::text())">
  119. <xsl:copy-of select="$mark"/>
  120. </xsl:if>
  121. <xsl:copy/>
  122. </xsl:template>
  123. <xsl:template match="processing-instruction()|comment()" mode="insert.fo.text">
  124. <xsl:param name="mark" select="'?'"/>
  125. <xsl:copy/>
  126. </xsl:template>
  127. <!-- ==================================================================== -->
  128. </xsl:stylesheet>