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"
8 <!-- ********************************************************************
9 $Id: math.xsl 7503 2007-10-08 01:57:30Z xmldoc $
10 ********************************************************************
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
16 ******************************************************************** -->
18 <xsl:template match="inlineequation">
20 <xsl:when test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
21 <xsl:apply-templates select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']">
22 <xsl:with-param name="output.delims">
23 <xsl:call-template name="tex.math.output.delims"/>
25 </xsl:apply-templates>
28 <xsl:apply-templates/>
33 <xsl:template match="alt">
36 <xsl:template match="mathphrase">
38 <xsl:apply-templates/>
42 <!-- "Support" for MathML -->
44 <xsl:template match="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML">
46 <!-- * If user is using passivetex, we don't wrap the output in -->
47 <!-- * fo:instream-foreign-object (which passivetex doesn't support). -->
48 <xsl:when test="not($passivetex.extensions = 0)">
50 <xsl:copy-of select="@*"/>
51 <xsl:apply-templates/>
55 <fo:instream-foreign-object>
57 <xsl:copy-of select="@*"/>
58 <xsl:apply-templates/>
60 </fo:instream-foreign-object>
65 <xsl:template match="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
67 <xsl:copy-of select="@*"/>
68 <xsl:apply-templates/>
72 <xsl:template match="equation/graphic | informalequation/graphic">
73 <xsl:if test="$passivetex.extensions = 0 or $tex.math.in.alt = ''">
75 <xsl:call-template name="process.image"/>
80 <xsl:template match="inlineequation/alt[@role='tex'] |
81 inlineequation/inlinemediaobject/textobject[@role='tex']" priority="1">
82 <xsl:param name="output.delims" select="1"/>
83 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
84 <xsl:processing-instruction name="xmltex">
85 <xsl:if test="$output.delims != 0">
86 <xsl:text>$</xsl:text>
88 <xsl:value-of select="."/>
89 <xsl:if test="$output.delims != 0">
90 <xsl:text>$</xsl:text>
92 </xsl:processing-instruction>
96 <xsl:template match="equation/alt[@role='tex'] | informalequation/alt[@role='tex'] |
97 equation/mediaobject/textobject[@role='tex'] |
98 informalequation/mediaobject/textobject[@role='tex']" priority="1">
99 <xsl:variable name="output.delims">
100 <xsl:call-template name="tex.math.output.delims"/>
102 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
103 <xsl:processing-instruction name="xmltex">
104 <xsl:if test="$output.delims != 0">
105 <xsl:text>$$</xsl:text>
107 <xsl:value-of select="."/>
108 <xsl:if test="$output.delims != 0">
109 <xsl:text>$$</xsl:text>
111 </xsl:processing-instruction>
115 <xsl:template match="alt[@role='tex']">
116 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
118 Your equation is misplaced. It should be in inlineequation, equation or informalequation.
123 <xsl:template name="tex.math.output.delims">
124 <xsl:variable name="pi.delims">
125 <xsl:call-template name="pi-attribute">
126 <xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
127 <xsl:with-param name="attribute" select="'delims'"/>
130 <xsl:variable name="result">
132 <xsl:when test="$pi.delims = 'no'">0</xsl:when>
133 <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
134 <xsl:otherwise>1</xsl:otherwise>
137 <xsl:value-of select="$result"/>