math.xsl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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:mml="http://www.w3.org/1998/Math/MathML"
  5. exclude-result-prefixes="mml"
  6. version='1.0'>
  7. <!-- ********************************************************************
  8. $Id: math.xsl 9647 2012-10-26 17:42:03Z bobstayton $
  9. ********************************************************************
  10. This file is part of the XSL DocBook Stylesheet distribution.
  11. See ../README or http://docbook.sf.net/release/xsl/current/ for
  12. copyright and other information.
  13. ******************************************************************** -->
  14. <xsl:template match="inlineequation">
  15. <xsl:apply-templates/>
  16. </xsl:template>
  17. <xsl:template match="alt">
  18. </xsl:template>
  19. <xsl:template match="mathphrase">
  20. <fo:inline>
  21. <xsl:apply-templates/>
  22. </fo:inline>
  23. </xsl:template>
  24. <!-- "Support" for MathML -->
  25. <xsl:template match="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML">
  26. <fo:instream-foreign-object>
  27. <xsl:copy>
  28. <xsl:copy-of select="@*"/>
  29. <xsl:apply-templates/>
  30. </xsl:copy>
  31. </fo:instream-foreign-object>
  32. </xsl:template>
  33. <xsl:template match="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
  34. <xsl:copy>
  35. <xsl:copy-of select="@*"/>
  36. <xsl:apply-templates/>
  37. </xsl:copy>
  38. </xsl:template>
  39. <xsl:template match="equation/graphic | informalequation/graphic">
  40. <xsl:if test="$tex.math.in.alt = ''">
  41. <fo:block>
  42. <xsl:call-template name="process.image"/>
  43. </fo:block>
  44. </xsl:if>
  45. </xsl:template>
  46. <xsl:template match="inlineequation/alt[@role='tex'] |
  47. inlineequation/inlinemediaobject/textobject[@role='tex']" priority="1">
  48. <xsl:param name="output.delims" select="1"/>
  49. </xsl:template>
  50. <xsl:template match="equation/alt[@role='tex'] | informalequation/alt[@role='tex'] |
  51. equation/mediaobject/textobject[@role='tex'] |
  52. informalequation/mediaobject/textobject[@role='tex']" priority="1">
  53. <xsl:variable name="output.delims">
  54. <xsl:call-template name="tex.math.output.delims"/>
  55. </xsl:variable>
  56. </xsl:template>
  57. <xsl:template name="tex.math.output.delims">
  58. <xsl:variable name="pi.delims">
  59. <xsl:call-template name="pi-attribute">
  60. <xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
  61. <xsl:with-param name="attribute" select="'delims'"/>
  62. </xsl:call-template>
  63. </xsl:variable>
  64. <xsl:variable name="result">
  65. <xsl:choose>
  66. <xsl:when test="$pi.delims = 'no'">0</xsl:when>
  67. <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
  68. <xsl:otherwise>1</xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:variable>
  71. <xsl:value-of select="$result"/>
  72. </xsl:template>
  73. </xsl:stylesheet>