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