source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/math.xsl@ 572513f

Last change on this file since 572513f was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 4.2 KB
Line 
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<!-- ********************************************************************
9 $Id$
10 ********************************************************************
11
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.
15
16 ******************************************************************** -->
17
18<xsl:template match="inlineequation">
19 <xsl:choose>
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"/>
24 </xsl:with-param>
25 </xsl:apply-templates>
26 </xsl:when>
27 <xsl:otherwise>
28 <xsl:apply-templates/>
29 </xsl:otherwise>
30 </xsl:choose>
31</xsl:template>
32
33<xsl:template match="alt">
34</xsl:template>
35
36<xsl:template match="mathphrase">
37 <fo:inline>
38 <xsl:apply-templates/>
39 </fo:inline>
40</xsl:template>
41
42<!-- "Support" for MathML -->
43
44<xsl:template match="mml:math" xmlns:mml="http://www.w3.org/1998/Math/MathML">
45 <fo:instream-foreign-object>
46 <xsl:copy>
47 <xsl:copy-of select="@*"/>
48 <xsl:apply-templates/>
49 </xsl:copy>
50 </fo:instream-foreign-object>
51</xsl:template>
52
53<xsl:template match="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
54 <xsl:copy>
55 <xsl:copy-of select="@*"/>
56 <xsl:apply-templates/>
57 </xsl:copy>
58</xsl:template>
59
60<xsl:template match="equation/graphic | informalequation/graphic">
61 <xsl:if test="$passivetex.extensions = 0 or $tex.math.in.alt = ''">
62 <fo:block>
63 <xsl:call-template name="process.image"/>
64 </fo:block>
65 </xsl:if>
66</xsl:template>
67
68<xsl:template match="inlineequation/alt[@role='tex'] |
69 inlineequation/inlinemediaobject/textobject[@role='tex']" priority="1">
70 <xsl:param name="output.delims" select="1"/>
71 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
72 <xsl:processing-instruction name="xmltex">
73 <xsl:if test="$output.delims != 0">
74 <xsl:text>$</xsl:text>
75 </xsl:if>
76 <xsl:value-of select="."/>
77 <xsl:if test="$output.delims != 0">
78 <xsl:text>$</xsl:text>
79 </xsl:if>
80 </xsl:processing-instruction>
81 </xsl:if>
82</xsl:template>
83
84<xsl:template match="equation/alt[@role='tex'] | informalequation/alt[@role='tex'] |
85 equation/mediaobject/textobject[@role='tex'] |
86 informalequation/mediaobject/textobject[@role='tex']" priority="1">
87 <xsl:variable name="output.delims">
88 <xsl:call-template name="tex.math.output.delims"/>
89 </xsl:variable>
90 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
91 <xsl:processing-instruction name="xmltex">
92 <xsl:if test="$output.delims != 0">
93 <xsl:text>$$</xsl:text>
94 </xsl:if>
95 <xsl:value-of select="."/>
96 <xsl:if test="$output.delims != 0">
97 <xsl:text>$$</xsl:text>
98 </xsl:if>
99 </xsl:processing-instruction>
100 </xsl:if>
101</xsl:template>
102
103<xsl:template match="alt[@role='tex']">
104 <xsl:if test="$passivetex.extensions != 0 and $tex.math.in.alt != ''">
105 <xsl:message>
106 Your equation is misplaced. It should be in inlineequation, equation or informalequation.
107 </xsl:message>
108 </xsl:if>
109</xsl:template>
110
111<xsl:template name="tex.math.output.delims">
112 <xsl:variable name="pi.delims">
113 <xsl:call-template name="pi-attribute">
114 <xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
115 <xsl:with-param name="attribute" select="'delims'"/>
116 </xsl:call-template>
117 </xsl:variable>
118 <xsl:variable name="result">
119 <xsl:choose>
120 <xsl:when test="$pi.delims = 'no'">0</xsl:when>
121 <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
122 <xsl:otherwise>1</xsl:otherwise>
123 </xsl:choose>
124 </xsl:variable>
125 <xsl:value-of select="$result"/>
126</xsl:template>
127
128</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.