fo.xsl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. version='1.0'>
  5. <!-- ********************************************************************
  6. $Id: fo.xsl 9720 2013-01-31 18:24:47Z bobstayton $
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- These variables set the margin-left or -right attribute value for FO output based on
  13. the writing-mode specified in the gentext file for the document's lang. -->
  14. <xsl:param name="direction.align.start">
  15. <xsl:choose>
  16. <!-- FOP does not support writing-mode="rl-tb" -->
  17. <xsl:when test="$fop.extensions != 0">left</xsl:when>
  18. <xsl:when test="$fop1.extensions != 0">left</xsl:when>
  19. <xsl:when test="starts-with($writing.mode, 'lr')">left</xsl:when>
  20. <xsl:when test="starts-with($writing.mode, 'rl')">right</xsl:when>
  21. <xsl:when test="starts-with($writing.mode, 'tb')">top</xsl:when>
  22. <xsl:otherwise>left</xsl:otherwise>
  23. </xsl:choose>
  24. </xsl:param>
  25. <xsl:param name="direction.align.end">
  26. <xsl:choose>
  27. <xsl:when test="$fop.extensions != 0">right</xsl:when>
  28. <xsl:when test="$fop1.extensions != 0">right</xsl:when>
  29. <xsl:when test="starts-with($writing.mode, 'lr')">right</xsl:when>
  30. <xsl:when test="starts-with($writing.mode, 'rl')">left</xsl:when>
  31. <xsl:when test="starts-with($writing.mode, 'tb')">bottom</xsl:when>
  32. <xsl:otherwise>right</xsl:otherwise>
  33. </xsl:choose>
  34. </xsl:param>
  35. <xsl:param name="direction.mode">
  36. <xsl:choose>
  37. <xsl:when test="$fop.extensions != 0 and
  38. starts-with($writing.mode, 'rl')">
  39. <xsl:message>WARNING: FOP does not support right-to-left writing-mode</xsl:message>
  40. <xsl:text>lr-tb</xsl:text>
  41. </xsl:when>
  42. <xsl:when test="$fop1.extensions != 0 and
  43. starts-with($writing.mode, 'rl')">
  44. <xsl:message>WARNING: FOP does not support right-to-left writing-mode</xsl:message>
  45. <xsl:text>lr-tb</xsl:text>
  46. </xsl:when>
  47. <xsl:when test="starts-with($writing.mode, 'lr')">lr-tb</xsl:when>
  48. <xsl:when test="starts-with($writing.mode, 'rl')">rl-tb</xsl:when>
  49. <xsl:when test="starts-with($writing.mode, 'tb')">tb-rl</xsl:when>
  50. <xsl:otherwise>lr-tb</xsl:otherwise>
  51. </xsl:choose>
  52. </xsl:param>
  53. <xsl:template name="anchor">
  54. <xsl:param name="node" select="."/>
  55. <xsl:param name="conditional" select="1"/>
  56. <xsl:variable name="id">
  57. <xsl:call-template name="object.id">
  58. <xsl:with-param name="object" select="$node"/>
  59. </xsl:call-template>
  60. </xsl:variable>
  61. <xsl:if test="$conditional = 0 or $node/@id or $node/@xml:id">
  62. <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
  63. </xsl:if>
  64. </xsl:template>
  65. <xsl:template name="dingbat">
  66. <xsl:param name="dingbat">bullet</xsl:param>
  67. <xsl:variable name="symbol">
  68. <xsl:choose>
  69. <xsl:when test="$dingbat='bullet'">o</xsl:when>
  70. <xsl:when test="$dingbat='copyright'">&#x00A9;</xsl:when>
  71. <xsl:when test="$dingbat='trademark'">&#x2122;</xsl:when>
  72. <xsl:when test="$dingbat='trade'">&#x2122;</xsl:when>
  73. <xsl:when test="$dingbat='registered'">&#x00AE;</xsl:when>
  74. <xsl:when test="$dingbat='service'">(SM)</xsl:when>
  75. <xsl:when test="$dingbat='ldquo'">"</xsl:when>
  76. <xsl:when test="$dingbat='rdquo'">"</xsl:when>
  77. <xsl:when test="$dingbat='lsquo'">'</xsl:when>
  78. <xsl:when test="$dingbat='rsquo'">'</xsl:when>
  79. <xsl:when test="$dingbat='em-dash'">&#x2014;</xsl:when>
  80. <xsl:when test="$dingbat='en-dash'">-</xsl:when>
  81. <xsl:otherwise>o</xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:variable>
  84. <xsl:choose>
  85. <xsl:when test="$dingbat.fontset = ''">
  86. <xsl:copy-of select="$symbol"/>
  87. </xsl:when>
  88. <xsl:otherwise>
  89. <fo:inline font-family="{$dingbat.fontset}">
  90. <xsl:copy-of select="$symbol"/>
  91. </fo:inline>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:template>
  95. <xsl:template name="href.target">
  96. <xsl:param name="context" select="."/>
  97. <xsl:param name="object" select="."/>
  98. <xsl:text>#</xsl:text>
  99. <xsl:call-template name="object.id">
  100. <xsl:with-param name="object" select="$object"/>
  101. </xsl:call-template>
  102. </xsl:template>
  103. </xsl:stylesheet>