| 1 |
<?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="mml d" version="1.0"> |
| 2 |
|
| 3 |
<!-- ******************************************************************** |
| 4 |
|
| 5 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 6 |
See ../README or http://cdn.docbook.org/release/xsl/current/ for |
| 7 |
copyright and other information. |
| 8 |
|
| 9 |
******************************************************************** --> |
| 10 |
|
| 11 |
<xsl:template match="d:inlineequation"> |
| 12 |
<xsl:apply-templates/> |
| 13 |
</xsl:template> |
| 14 |
|
| 15 |
<xsl:template match="d:alt"> |
| 16 |
</xsl:template> |
| 17 |
|
| 18 |
<xsl:template match="d:mathphrase"> |
| 19 |
<span> |
| 20 |
<xsl:apply-templates select="." mode="common.html.attributes"/> |
| 21 |
<xsl:call-template name="id.attribute"/> |
| 22 |
<xsl:apply-templates/> |
| 23 |
</span> |
| 24 |
</xsl:template> |
| 25 |
|
| 26 |
<!-- "Support" for MathML --> |
| 27 |
|
| 28 |
<xsl:template match="mml:*"> |
| 29 |
<xsl:copy> |
| 30 |
<xsl:copy-of select="@*"/> |
| 31 |
<xsl:apply-templates/> |
| 32 |
</xsl:copy> |
| 33 |
</xsl:template> |
| 34 |
|
| 35 |
<!-- Support for TeX math in alt --> |
| 36 |
|
| 37 |
<xsl:template match="*" mode="collect.tex.math"> |
| 38 |
<xsl:call-template name="write.text.chunk"> |
| 39 |
<xsl:with-param name="filename" select="$tex.math.file"/> |
| 40 |
<xsl:with-param name="method" select="'text'"/> |
| 41 |
<xsl:with-param name="content"> |
| 42 |
<xsl:choose> |
| 43 |
<xsl:when test="$tex.math.in.alt = 'plain'"> |
| 44 |
<xsl:call-template name="tex.math.plain.head"/> |
| 45 |
<xsl:apply-templates select="." mode="collect.tex.math.plain"/> |
| 46 |
<xsl:call-template name="tex.math.plain.tail"/> |
| 47 |
</xsl:when> |
| 48 |
<xsl:when test="$tex.math.in.alt = 'latex'"> |
| 49 |
<xsl:call-template name="tex.math.latex.head"/> |
| 50 |
<xsl:apply-templates select="." mode="collect.tex.math.latex"/> |
| 51 |
<xsl:call-template name="tex.math.latex.tail"/> |
| 52 |
</xsl:when> |
| 53 |
<xsl:otherwise> |
| 54 |
<xsl:message> |
| 55 |
Unsupported TeX math notation: |
| 56 |
<xsl:value-of select="$tex.math.in.alt"/> |
| 57 |
</xsl:message> |
| 58 |
</xsl:otherwise> |
| 59 |
</xsl:choose> |
| 60 |
</xsl:with-param> |
| 61 |
<xsl:with-param name="encoding" select="$chunker.output.encoding"/> |
| 62 |
</xsl:call-template> |
| 63 |
</xsl:template> |
| 64 |
|
| 65 |
<!-- PlainTeX --> |
| 66 |
|
| 67 |
<xsl:template name="tex.math.plain.head"> |
| 68 |
<xsl:text>\nopagenumbers |
| 69 |
</xsl:text> |
| 70 |
</xsl:template> |
| 71 |
|
| 72 |
<xsl:template name="tex.math.plain.tail"> |
| 73 |
<xsl:text>\bye |
| 74 |
</xsl:text> |
| 75 |
</xsl:template> |
| 76 |
|
| 77 |
<xsl:template match="d:inlineequation" mode="collect.tex.math.plain"> |
| 78 |
<xsl:variable name="filename"> |
| 79 |
<xsl:choose> |
| 80 |
<xsl:when test="d:graphic"> |
| 81 |
<xsl:call-template name="mediaobject.filename"> |
| 82 |
<xsl:with-param name="object" select="d:graphic"/> |
| 83 |
</xsl:call-template> |
| 84 |
</xsl:when> |
| 85 |
<xsl:otherwise> |
| 86 |
<xsl:call-template name="select.mediaobject.filename"> |
| 87 |
<xsl:with-param name="olist" select="d:inlinemediaobject/*"/> |
| 88 |
</xsl:call-template> |
| 89 |
</xsl:otherwise> |
| 90 |
</xsl:choose> |
| 91 |
</xsl:variable> |
| 92 |
<xsl:variable name="output.delims"> |
| 93 |
<xsl:call-template name="tex.math.output.delims"/> |
| 94 |
</xsl:variable> |
| 95 |
<xsl:variable name="tex" select="d:alt[@role='tex'] | d:inlinemediaobject/d:textobject[@role='tex']"/> |
| 96 |
<xsl:if test="$tex"> |
| 97 |
<xsl:text>\special{dvi2bitmap outputfile </xsl:text> |
| 98 |
<xsl:value-of select="$filename"/> |
| 99 |
<xsl:text>} |
| 100 |
</xsl:text> |
| 101 |
<xsl:if test="$output.delims != 0"> |
| 102 |
<xsl:text>$</xsl:text> |
| 103 |
</xsl:if> |
| 104 |
<xsl:value-of select="$tex"/> |
| 105 |
<xsl:if test="$output.delims != 0"> |
| 106 |
<xsl:text>$ |
| 107 |
</xsl:text> |
| 108 |
</xsl:if> |
| 109 |
<xsl:text>\vfill\eject |
| 110 |
</xsl:text> |
| 111 |
</xsl:if> |
| 112 |
</xsl:template> |
| 113 |
|
| 114 |
<xsl:template match="d:equation|d:informalequation" mode="collect.tex.math.plain"> |
| 115 |
<xsl:variable name="filename"> |
| 116 |
<xsl:choose> |
| 117 |
<xsl:when test="d:graphic"> |
| 118 |
<xsl:call-template name="mediaobject.filename"> |
| 119 |
<xsl:with-param name="object" select="d:graphic"/> |
| 120 |
</xsl:call-template> |
| 121 |
</xsl:when> |
| 122 |
<xsl:otherwise> |
| 123 |
<xsl:call-template name="select.mediaobject.filename"> |
| 124 |
<xsl:with-param name="olist" select="d:mediaobject/*"/> |
| 125 |
</xsl:call-template> |
| 126 |
</xsl:otherwise> |
| 127 |
</xsl:choose> |
| 128 |
</xsl:variable> |
| 129 |
<xsl:variable name="output.delims"> |
| 130 |
<xsl:call-template name="tex.math.output.delims"/> |
| 131 |
</xsl:variable> |
| 132 |
<xsl:variable name="tex" select="d:alt[@role='tex'] | d:mediaobject/d:textobject[@role='tex']"/> |
| 133 |
<xsl:if test="$tex"> |
| 134 |
<xsl:text>\special{dvi2bitmap outputfile </xsl:text> |
| 135 |
<xsl:value-of select="$filename"/> |
| 136 |
<xsl:text>} |
| 137 |
</xsl:text> |
| 138 |
<xsl:if test="$output.delims != 0"> |
| 139 |
<xsl:text>$$</xsl:text> |
| 140 |
</xsl:if> |
| 141 |
<xsl:value-of select="$tex"/> |
| 142 |
<xsl:if test="$output.delims != 0"> |
| 143 |
<xsl:text>$$ |
| 144 |
</xsl:text> |
| 145 |
</xsl:if> |
| 146 |
<xsl:text>\vfill\eject |
| 147 |
</xsl:text> |
| 148 |
</xsl:if> |
| 149 |
</xsl:template> |
| 150 |
|
| 151 |
<xsl:template match="text()" mode="collect.tex.math.plain"/> |
| 152 |
|
| 153 |
<!-- LaTeX --> |
| 154 |
|
| 155 |
<xsl:template name="tex.math.latex.head"> |
| 156 |
<xsl:text>\documentclass{article} |
| 157 |
</xsl:text> |
| 158 |
<xsl:text>\pagestyle{empty} |
| 159 |
</xsl:text> |
| 160 |
<xsl:text>\begin{document} |
| 161 |
</xsl:text> |
| 162 |
</xsl:template> |
| 163 |
|
| 164 |
<xsl:template name="tex.math.latex.tail"> |
| 165 |
<xsl:text>\end{document} |
| 166 |
</xsl:text> |
| 167 |
</xsl:template> |
| 168 |
|
| 169 |
<xsl:template match="d:inlineequation" mode="collect.tex.math.latex"> |
| 170 |
<xsl:variable name="filename"> |
| 171 |
<xsl:choose> |
| 172 |
<xsl:when test="d:graphic"> |
| 173 |
<xsl:call-template name="mediaobject.filename"> |
| 174 |
<xsl:with-param name="object" select="d:graphic"/> |
| 175 |
</xsl:call-template> |
| 176 |
</xsl:when> |
| 177 |
<xsl:otherwise> |
| 178 |
<xsl:call-template name="select.mediaobject.filename"> |
| 179 |
<xsl:with-param name="olist" select="d:inlinemediaobject/*"/> |
| 180 |
</xsl:call-template> |
| 181 |
</xsl:otherwise> |
| 182 |
</xsl:choose> |
| 183 |
</xsl:variable> |
| 184 |
<xsl:variable name="output.delims"> |
| 185 |
<xsl:call-template name="tex.math.output.delims"/> |
| 186 |
</xsl:variable> |
| 187 |
<xsl:variable name="tex" select="d:alt[@role='tex'] | d:inlinemediaobject/d:textobject[@role='tex']"/> |
| 188 |
<xsl:if test="$tex"> |
| 189 |
<xsl:text>\special{dvi2bitmap outputfile </xsl:text> |
| 190 |
<xsl:value-of select="$filename"/> |
| 191 |
<xsl:text>} |
| 192 |
</xsl:text> |
| 193 |
<xsl:if test="$output.delims != 0"> |
| 194 |
<xsl:text>$</xsl:text> |
| 195 |
</xsl:if> |
| 196 |
<xsl:value-of select="$tex"/> |
| 197 |
<xsl:if test="$output.delims != 0"> |
| 198 |
<xsl:text>$ |
| 199 |
</xsl:text> |
| 200 |
</xsl:if> |
| 201 |
<xsl:text>\newpage |
| 202 |
</xsl:text> |
| 203 |
</xsl:if> |
| 204 |
</xsl:template> |
| 205 |
|
| 206 |
<xsl:template match="d:equation|d:informalequation" mode="collect.tex.math.latex"> |
| 207 |
<xsl:variable name="filename"> |
| 208 |
<xsl:choose> |
| 209 |
<xsl:when test="d:graphic"> |
| 210 |
<xsl:call-template name="mediaobject.filename"> |
| 211 |
<xsl:with-param name="object" select="d:graphic"/> |
| 212 |
</xsl:call-template> |
| 213 |
</xsl:when> |
| 214 |
<xsl:otherwise> |
| 215 |
<xsl:call-template name="select.mediaobject.filename"> |
| 216 |
<xsl:with-param name="olist" select="d:mediaobject/*"/> |
| 217 |
</xsl:call-template> |
| 218 |
</xsl:otherwise> |
| 219 |
</xsl:choose> |
| 220 |
</xsl:variable> |
| 221 |
<xsl:variable name="output.delims"> |
| 222 |
<xsl:call-template name="tex.math.output.delims"/> |
| 223 |
</xsl:variable> |
| 224 |
<xsl:variable name="tex" select="d:alt[@role='tex'] | d:mediaobject/d:textobject[@role='tex']"/> |
| 225 |
<xsl:if test="$tex"> |
| 226 |
<xsl:text>\special{dvi2bitmap outputfile </xsl:text> |
| 227 |
<xsl:value-of select="$filename"/> |
| 228 |
<xsl:text>} |
| 229 |
</xsl:text> |
| 230 |
<xsl:if test="$output.delims != 0"> |
| 231 |
<xsl:text>$$</xsl:text> |
| 232 |
</xsl:if> |
| 233 |
<xsl:value-of select="$tex"/> |
| 234 |
<xsl:if test="$output.delims != 0"> |
| 235 |
<xsl:text>$$ |
| 236 |
</xsl:text> |
| 237 |
</xsl:if> |
| 238 |
<xsl:text>\newpage |
| 239 |
</xsl:text> |
| 240 |
</xsl:if> |
| 241 |
</xsl:template> |
| 242 |
|
| 243 |
<xsl:template match="text()" mode="collect.tex.math.latex"/> |
| 244 |
|
| 245 |
<!-- Extracting image filename from mediaobject and graphic elements --> |
| 246 |
|
| 247 |
<xsl:template name="select.mediaobject.filename"> |
| 248 |
<xsl:param name="olist" select="d:imageobject|d:imageobjectco |d:videoobject|d:audioobject|d:textobject"/> |
| 249 |
|
| 250 |
<xsl:variable name="mediaobject.index"> |
| 251 |
<xsl:call-template name="select.mediaobject.index"> |
| 252 |
<xsl:with-param name="olist" select="$olist"/> |
| 253 |
<xsl:with-param name="count" select="1"/> |
| 254 |
</xsl:call-template> |
| 255 |
</xsl:variable> |
| 256 |
|
| 257 |
<xsl:if test="$mediaobject.index != ''"> |
| 258 |
<xsl:call-template name="mediaobject.filename"> |
| 259 |
<xsl:with-param name="object" select="$olist[position() = $mediaobject.index]"/> |
| 260 |
</xsl:call-template> |
| 261 |
</xsl:if> |
| 262 |
</xsl:template> |
| 263 |
|
| 264 |
<xsl:template name="tex.math.output.delims"> |
| 265 |
<xsl:variable name="pi.delims"> |
| 266 |
<xsl:call-template name="pi.dbtex_delims"> |
| 267 |
<xsl:with-param name="node" select="descendant-or-self::*"/> |
| 268 |
</xsl:call-template> |
| 269 |
</xsl:variable> |
| 270 |
<xsl:variable name="result"> |
| 271 |
<xsl:choose> |
| 272 |
<xsl:when test="$pi.delims = 'no'">0</xsl:when> |
| 273 |
<xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when> |
| 274 |
<xsl:otherwise>1</xsl:otherwise> |
| 275 |
</xsl:choose> |
| 276 |
</xsl:variable> |
| 277 |
<xsl:value-of select="$result"/> |
| 278 |
</xsl:template> |
| 279 |
|
| 280 |
</xsl:stylesheet> |