Replacing old XSLT transform for math with MathJax
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@161 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
3dff4f20b4
commit
fbd7e66412
39 changed files with 128 additions and 1794 deletions
|
@ -2,6 +2,10 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
|
|||
|
||||
---------- version 1.3.1 alpha ----------
|
||||
|
||||
[w2x] Support for the obsolete output format XHTML+MahtML+XSL has been removed (replaced by MathJax). As a consequence
|
||||
the option xslt_path has been removed. Also the vacant spot in the export dialog is now used for the option use_mathjax
|
||||
(only active for XHTML+MathML and HTML5)
|
||||
|
||||
[w2l] Added support for TexMaths equations in LaTeX, XHTML+MathML and HTML5 (the last two only if use_mathjax=true)
|
||||
|
||||
[all] The command line application now gives an explanation if the source file is not in ODF format
|
||||
|
|
Binary file not shown.
|
@ -1,612 +0,0 @@
|
|||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:mml="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
|
||||
xmlns:fns="http://www.w3.org/2002/Math/preference"
|
||||
xmlns:doc="http://www.dcarlisle.demon.co.uk/xsldoc"
|
||||
xmlns:ie5="http://www.w3.org/TR/WD-xsl"
|
||||
exclude-result-prefixes="h ie5 fns msxsl fns doc"
|
||||
extension-element-prefixes="msxsl fns doc"
|
||||
>
|
||||
|
||||
<!--
|
||||
$Id: pmathml.xsl,v 1.8 2003/06/23 14:46:44 davidc Exp $
|
||||
|
||||
Copyright David Carlisle 2001, 2002.
|
||||
|
||||
Use and distribution of this code are permitted under the terms of the <a
|
||||
href="http://www.w3.org/Consortium/Legal/copyright-software-19980720"
|
||||
>W3C Software Notice and License</a>.
|
||||
-->
|
||||
|
||||
<!-- MathPlayer mpdialog code for contributed by
|
||||
Jack Dignan and Robert Miner, both of Design Science.
|
||||
-->
|
||||
|
||||
<xsl:output method="xml" omit-xml-declaration="yes" />
|
||||
|
||||
<ie5:if doc:id="iehack" test=".">
|
||||
<ie5:eval no-entities="t">'<!--'</ie5:eval>
|
||||
</ie5:if>
|
||||
|
||||
|
||||
<fns:x name="mathplayer" o="MathPlayer.Factory.1">
|
||||
<object id="mmlFactory"
|
||||
classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
|
||||
</object>
|
||||
<?import namespace="mml" implementation="#mmlFactory"?>
|
||||
</fns:x>
|
||||
|
||||
<fns:x name="techexplorer" o="techexplorer.AxTchExpCtrl.1">
|
||||
<object id="mmlFactory" classid="clsid:0E76D59A-C088-11D4-9920-002035EFB1A4">
|
||||
</object>
|
||||
<?import namespace="mml" implementation="#mmlFactory"?>
|
||||
</fns:x>
|
||||
|
||||
|
||||
<!-- SCRIPT not script due to weird mozilla bug
|
||||
http://bugzilla.mozilla.org/show_bug.cgi?id=158457
|
||||
-->
|
||||
|
||||
<fns:x name="css" o="Microsoft.FreeThreadedXMLDOM">
|
||||
<SCRIPT for="window" event="onload">
|
||||
var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");
|
||||
xsl.async = false;
|
||||
xsl.validateOnParse = false;
|
||||
xsl.load("pmathmlcss.xsl");
|
||||
var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0");
|
||||
xslTemplate.stylesheet=xsl.documentElement;
|
||||
var xslProc = xslTemplate.createProcessor();
|
||||
xslProc.input = document.XMLDocument;
|
||||
xslProc.transform();
|
||||
var str = xslProc.output;
|
||||
<!-- work around bug in IE6 under Win XP, RM 6/5/2002 -->
|
||||
var repl = "replace";
|
||||
if (window.navigator.appVersion.match(/Windows NT 5.1/)) { repl = ""; }
|
||||
var newDoc = document.open("text/html", repl);
|
||||
newDoc.write(str);
|
||||
</SCRIPT>
|
||||
</fns:x>
|
||||
|
||||
|
||||
<h:p>
|
||||
in mpdialog mode, we just write out some JavaScript to display
|
||||
dialog to the reader asking whether they want to install MathPlayer
|
||||
Depending on the response we get, we then instantiate an XSL processor
|
||||
and reprocess the doc, passing $secondpass according to the
|
||||
reader response.
|
||||
</h:p>
|
||||
<h:p>Using d-o-e is fairly horrible, but this code is only for IE
|
||||
anyway, and we need to force HTML semantics in this case.</h:p>
|
||||
|
||||
<xsl:variable name="mpdialog">
|
||||
var cookieName = "MathPlayerInstall=";
|
||||
function MPInstall(){
|
||||
var showDialog=true;
|
||||
var c = document.cookie;
|
||||
var i = c.indexOf(cookieName);
|
||||
if (i >= 0) {
|
||||
if ( c.substr(i + cookieName.length, 1) >= 2) { showDialog=false; }
|
||||
}
|
||||
if (showDialog) {
|
||||
MPDialog();
|
||||
c = document.cookie;
|
||||
i = c.indexOf(cookieName);
|
||||
}
|
||||
if (i >= 0) return c.substr(i + cookieName.length, 1);
|
||||
else return null;
|
||||
}
|
||||
|
||||
function MPDialog() {
|
||||
var vArgs="";
|
||||
var sFeatures="dialogWidth:410px;dialogHeight:190px;help:off;status:no";
|
||||
var text = "";
|
||||
text += "javascript:document.write('"
|
||||
text += '<script>'
|
||||
text += 'function fnClose(v) { '
|
||||
text += 'var exp = new Date();'
|
||||
text += 'var thirtyDays = exp.getTime() + (30 * 24 * 60 * 60 * 1000);'
|
||||
text += 'exp.setTime(thirtyDays);'
|
||||
text += 'var cookieProps = ";expires=" + exp.toGMTString();'
|
||||
text += 'if (document.forms[0].dontask.checked) v+=2;'
|
||||
text += 'document.cookie="' + cookieName + '"+v+cookieProps;'
|
||||
text += 'window.close();'
|
||||
text += '}'
|
||||
text += '</' + 'script>'
|
||||
text += '<head><title>Install MathPlayer?</title></head>'
|
||||
text += '<body bgcolor="#D4D0C8"><form>'
|
||||
text += '<table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>'
|
||||
text += '<tr><td align=left>This page requires Design Science\\\'s MathPlayer&trade;.<br>'
|
||||
text += 'Do you want to download and install MathPlayer?</td></tr>';
|
||||
text += '<tr><td align=center><input type="checkbox" name="dontask">'
|
||||
text += 'Don\\\'t ask me again</td></tr>'
|
||||
text += '<tr><td align=center><input id=yes type="button" value=" Yes "'
|
||||
text += ' onClick="fnClose(1)">&nbsp;&nbsp;&nbsp;'
|
||||
text += '<input type="button" value=" No " onClick="fnClose(0)"></td></tr>'
|
||||
text += '</table></form>';
|
||||
text += '</body>'
|
||||
text += "')"
|
||||
window.showModalDialog( text , vArgs, sFeatures );
|
||||
}
|
||||
|
||||
function WaitDialog() {
|
||||
var vArgs="";
|
||||
var sFeatures="dialogWidth:510px;dialogHeight:150px;help:off;status:no";
|
||||
var text = "";
|
||||
text += "javascript:document.write('"
|
||||
text += '<script>'
|
||||
text += 'window.onload=fnLoad;'
|
||||
text += 'function fnLoad() {document.forms[0].yes.focus();}'
|
||||
text += 'function fnClose(v) { '
|
||||
text += 'window.returnValue=v;'
|
||||
text += 'window.close();'
|
||||
text += '}'
|
||||
text += '</' + 'script>'
|
||||
text += '<head><title>Wait for Installation?</title></head>'
|
||||
text += '<body bgcolor="#D4D0C8" onload="fnLoad()"><form><'
|
||||
text += 'table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>'
|
||||
text += '<tr><td align=left>Click OK once MathPlayer is installed '
|
||||
text += 'to refresh the page.<br>'
|
||||
text += 'Click Cancel to view the page immediately without MathPlayer.</td></tr>';
|
||||
text += '<tr><td align=center><input id=yes type="button" '
|
||||
text += 'value=" OK " onClick="fnClose(1)">&nbsp;&nbsp;&nbsp;'
|
||||
text += '<input type="button" value="Cancel" onClick="fnClose(0)"></td></tr>'
|
||||
text += '</table></form>';
|
||||
text += '</body>'
|
||||
text += "')"
|
||||
return window.showModalDialog( text , vArgs, sFeatures );
|
||||
}
|
||||
|
||||
var result = MPInstall();
|
||||
|
||||
var action = "fallthrough";
|
||||
if (result == 1 || result == 3) {
|
||||
window.open("http://www.dessci.com/webmath/mathplayer");
|
||||
var wait = WaitDialog();
|
||||
if ( wait == 1) {
|
||||
action = "install";
|
||||
document.location.reload();
|
||||
|
||||
}
|
||||
}
|
||||
if (action == "fallthrough") {
|
||||
var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");
|
||||
xsl.async = false;
|
||||
xsl.validateOnParse = false;
|
||||
xsl.load("pmathmlcss.xsl");
|
||||
var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0");
|
||||
xslTemplate.stylesheet=xsl.documentElement;
|
||||
var xslProc = xslTemplate.createProcessor();
|
||||
xslProc.input = document.XMLDocument;
|
||||
|
||||
xslProc.transform();
|
||||
var str = xslProc.output;
|
||||
<!-- work around bug in IE6 under Win XP, RM 6/5/2002 -->
|
||||
var repl = "replace";
|
||||
if (window.navigator.appVersion.match(/Windows NT 5.1/)) { repl = ""; }
|
||||
var newDoc = document.open("text/html", repl);
|
||||
newDoc.write(str);
|
||||
document.close();
|
||||
}
|
||||
</xsl:variable>
|
||||
|
||||
<fns:x name="mathplayer-dl" >mathplayer-dl</fns:x>
|
||||
|
||||
<fns:x name="techexplorer-plugin" >techexplorer-plugin</fns:x>
|
||||
|
||||
<xsl:variable name="root" select="/"/>
|
||||
|
||||
|
||||
|
||||
<xsl:param name="activex">
|
||||
<xsl:choose>
|
||||
<xsl:when test="/*/@fns:renderer='techexplorer-plugin'">techexplorer-plugin</xsl:when>
|
||||
<xsl:when test="system-property('xsl:vendor')!='Microsoft'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="docpref" select="document('')/*/fns:x[@name=$root/*/@fns:renderer][1]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$docpref='mathplayer-dl'">mathplayer-dl</xsl:when>
|
||||
<xsl:when test="$docpref and fns:isinstalled(string($docpref/@o))='true'">
|
||||
<xsl:copy-of select="$docpref/node()"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="(document('')/*/fns:x[fns:isinstalled(string(@o))='true'])[1]/node()"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:param>
|
||||
|
||||
<h:div doc:ref="iehack">
|
||||
<h:h3>IE5 hacks</h:h3>
|
||||
<h:p>This code will be ignored by an XSLT engine as a top level
|
||||
element in a foreign namespace. It will be executed by an IE5XSL
|
||||
engine and insert <!-- into the output stream, ie the start of a
|
||||
comment. This will comment out all the XSLT code which will be copied
|
||||
to the output. A similar clause below will close this comment, it is
|
||||
then followed by the IE5XSL templates to be executed.</h:p>
|
||||
<h:p>This trick is due to Jonathan Marsh of Microsoft, and used in
|
||||
<h:a href="http://www.w3.org/TR/2001/WD-query-datamodel-20010607/xmlspec-ie-dm.xsl">the stylesheet for
|
||||
the XPath 2 data model draft</h:a>.</h:p>
|
||||
</h:div>
|
||||
|
||||
<h:h2>XSLT stylesheet</h:h2>
|
||||
<h:h3>MSXSL script block</h:h3>
|
||||
|
||||
<h:p>The following script block implements an extension function that
|
||||
tests whether a specified ActiveX component is known to the client.
|
||||
This is used below to test for the existence of MathML rendering
|
||||
components.</h:p>
|
||||
<msxsl:script language="JScript" implements-prefix="fns">
|
||||
function isinstalled(ax)
|
||||
{
|
||||
try {
|
||||
var ActiveX = new ActiveXObject(ax);
|
||||
return "true";
|
||||
} catch (e) {
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
</msxsl:script>
|
||||
|
||||
<h:p>The main bulk of this stylesheet is an identity transformation so...</h:p>
|
||||
<xsl:template match="*|comment()">
|
||||
<xsl:copy>
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<h:p>XHTML elements are copied sans prefix (XHTML is default namespace
|
||||
here, so these elements will still be in XHTML namespace</h:p>
|
||||
<xsl:template match="h:*">
|
||||
<xsl:element name="{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>IE's treatment of XHTML as HTML needs a little help here...</h:p>
|
||||
<xsl:template match="h:br|h:hr">
|
||||
<xsl:choose>
|
||||
<xsl:when test="system-property('xsl:vendor')='Microsoft'">
|
||||
<xsl:value-of disable-output-escaping="yes" select="concat('<',local-name(.))"/>
|
||||
<xsl:apply-templates mode="verb" select="@*"/>
|
||||
<xsl:text disable-output-escaping="yes">></xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>This just ensures the mathml prefix declaration isn't copied from
|
||||
the source at this stage, so that the system will use the mml prefix
|
||||
coming from this stylesheet</h:p>
|
||||
<xsl:template match="h:html|html">
|
||||
<html>
|
||||
<xsl:copy-of select="@*[not(namespace-uri(.)='http://www.w3.org/2002/Math/preference')]"/>
|
||||
<xsl:apply-templates/>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>We modify the head element to add code to specify a Microsoft
|
||||
"Behaviour" if the behaviour component is known to the system.</h:p>
|
||||
<h:span doc:ref="mp">Test for MathPlayer (Design Science)</h:span>
|
||||
<h:span doc:ref="te">Test for Techexplorer (IBM)</h:span>
|
||||
<h:span doc:ref="ms"><h:div>Test for Microsoft. In this case we just
|
||||
output a small HTML file that executes a script that will re-process
|
||||
the source docuument with a different stylesheet. Doing things this
|
||||
way avoids the need to xsl:import the second stylesheet, which would
|
||||
very much increase the processing overhead of running this
|
||||
stylesheet.</h:div></h:span>
|
||||
<h:span doc:ref="other">Further tests (eg for netscape/mozilla) could
|
||||
be added here if necessary</h:span>
|
||||
<xsl:template match="h:head|head">
|
||||
<head>
|
||||
|
||||
<!-- new if for IE frames bug -->
|
||||
<xsl:if test="system-property('xsl:vendor')='Microsoft'">
|
||||
<xsl:if test="name(msxsl:node-set($activex)/*)=''">
|
||||
<object id="mmlFactory"
|
||||
classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
|
||||
</object>
|
||||
<xsl:processing-instruction name="import">
|
||||
namespace="mml" implementation="#mmlFactory"
|
||||
</xsl:processing-instruction>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when doc:id="mp" test="$activex='mathplayer-dl'">
|
||||
<xsl:if test="fns:isinstalled('MathPlayer.Factory.1')='false'">
|
||||
<SCRIPT for="window" event="onload">
|
||||
<xsl:value-of select="$mpdialog" disable-output-escaping="yes"/>
|
||||
</SCRIPT>
|
||||
</xsl:if>
|
||||
<xsl:copy-of select="document('')/*/fns:x[@name='mathplayer']"/>
|
||||
</xsl:when>
|
||||
<xsl:when doc:id="mp" test="not($activex='techexplorer-plugin') and system-property('xsl:vendor')='Microsoft'">
|
||||
<xsl:copy-of select="$activex"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise doc:id="other">
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates/>
|
||||
</head>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="mml:math" priority="22">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$activex='techexplorer-plugin'">
|
||||
<embed type="text/mathml" height="75" width="300">
|
||||
<xsl:attribute name="mmldata">
|
||||
<xsl:apply-templates mode="verb" select="."/>
|
||||
</xsl:attribute>
|
||||
</embed>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="mml:{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- squash annotation elements -->
|
||||
|
||||
|
||||
|
||||
<h:p>Somewhat bizarrely in an otherwise namespace aware system,
|
||||
Microsoft behaviours are defined to trigger off the
|
||||
<h:em>prefix</h:em> not the <h:em>Namespace</h:em>. In the code above
|
||||
we associated a MathML rendering behaviour (if one was found) with the
|
||||
prefix <h:code>mml:</h:code> so here we ensure that this is the prefix
|
||||
that actually gets used in the output.</h:p>
|
||||
<xsl:template match="mml:*">
|
||||
<xsl:element name="mml:{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>Copy semantics element through in IE (so mathplayer gets to see
|
||||
mathplayer annotations, otherwise use first child or a presentation annotation.</h:p>
|
||||
<xsl:template match="mml:semantics">
|
||||
<xsl:choose>
|
||||
<xsl:when test="system-property('xsl:vendor')='Microsoft'">
|
||||
<xsl:element name="mml:{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="mml:annotation-xml[@encoding='MathML-Presentation']">
|
||||
<xsl:apply-templates select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- a version of my old verb.xsl -->
|
||||
|
||||
<!-- non empty elements and other nodes. -->
|
||||
<xsl:template mode="verb" match="*[*]|*[text()]|*[comment()]|*[processing-instruction()]">
|
||||
<xsl:value-of select="concat('<',local-name(.))"/>
|
||||
<xsl:apply-templates mode="verb" select="@*"/>
|
||||
<xsl:text>></xsl:text>
|
||||
<xsl:apply-templates mode="verb"/>
|
||||
<xsl:value-of select="concat('</',local-name(.),'>')"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- empty elements -->
|
||||
<xsl:template mode="verb" match="*">
|
||||
<xsl:value-of select="concat('<',local-name(.))"/>
|
||||
<xsl:apply-templates mode="verb" select="@*"/>
|
||||
<xsl:text>/></xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- attributes
|
||||
Output always surrounds attribute value by "
|
||||
so we need to make sure no literal " appear in the value -->
|
||||
<xsl:template mode="verb" match="@*">
|
||||
<xsl:value-of select="concat(' ',local-name(.),'=')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="from" select="'"'"/>
|
||||
<xsl:with-param name="to" select="'&quot;'"/>
|
||||
<xsl:with-param name="string" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- pis -->
|
||||
<xsl:template mode="verb" match="processing-instruction()"/>
|
||||
|
||||
<!-- only works if parser passes on comment nodes -->
|
||||
<xsl:template mode="verb" match="comment()"/>
|
||||
|
||||
|
||||
<!-- text elements
|
||||
need to replace & and < by entity references-->
|
||||
<xsl:template mode="verb" match="text()">
|
||||
<a name="{generate-id(.)}"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="to" select="'&gt;'"/>
|
||||
<xsl:with-param name="from" select="'>'"/>
|
||||
<xsl:with-param name="string">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="to" select="'&lt;'"/>
|
||||
<xsl:with-param name="from" select="'<'"/>
|
||||
<xsl:with-param name="string">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="to" select="'&amp;'"/>
|
||||
<xsl:with-param name="from" select="'&'"/>
|
||||
<xsl:with-param name="string" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- end verb mode -->
|
||||
|
||||
<!-- replace all occurences of the character(s) `from'
|
||||
by the string `to' in the string `string'.-->
|
||||
<xsl:template name="string-replace" >
|
||||
<xsl:param name="string"/>
|
||||
<xsl:param name="from"/>
|
||||
<xsl:param name="to"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($string,$from)">
|
||||
<xsl:value-of select="substring-before($string,$from)"/>
|
||||
<xsl:value-of select="$to"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="string" select="substring-after($string,$from)"/>
|
||||
<xsl:with-param name="from" select="$from"/>
|
||||
<xsl:with-param name="to" select="$to"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$string"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- end of verb.xsl -->
|
||||
|
||||
|
||||
|
||||
<h:h2>IE5XSL stylesheet</h:h2>
|
||||
<h:p>In a rare fit of sympathy for users of
|
||||
<h:em>the-language-known-as-XSL-in-IE5</h:em> this file incorporates a
|
||||
version of the above code designed to work in the Microsoft dialect.
|
||||
This is needed otherwise users of a MathML rendering behaviour would
|
||||
have to make a choice whether they wanted to use this stylesheet
|
||||
(keeping their source documents conforming XHTML+MathML) or to use
|
||||
the explicit Microsoft Object code, which is less portable, but would
|
||||
work in at least IE5.5.</h:p>
|
||||
|
||||
<h:p>This entire section of code, down to the end of the stylesheet is
|
||||
contained within this ie5:if. Thus XSLT sees it as a top level element
|
||||
from a foreign namespace and silently ignores it. IE5XSL sees it as
|
||||
"if true" and so executes the code.</h:p>
|
||||
|
||||
|
||||
<h:p doc:ref="closecomment">First close the comment started at the beginning. This ensures
|
||||
that the bulk of the XSLT code, while being copied to the result tree
|
||||
by the IE5XSL engine, will not be rendered in the browser.</h:p>
|
||||
|
||||
<h:span doc:ref="eval">Lacking attribute value templates in
|
||||
xsl:element, and the local-name() function, we resort to constructing
|
||||
the start and end tags in strings in javascript, then using
|
||||
no-entities attribute which is the IE5XSL equivalent of disable-output-encoding</h:span>
|
||||
<ie5:if test=".">
|
||||
|
||||
<ie5:eval doc:id="closecomment" no-entities="t">'-->'</ie5:eval>
|
||||
|
||||
<ie5:apply-templates select=".">
|
||||
|
||||
|
||||
<ie5:script>
|
||||
function mpisinstalled()
|
||||
{
|
||||
try {
|
||||
var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
|
||||
return "true";
|
||||
} catch (e) {
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
</ie5:script>
|
||||
|
||||
<ie5:template match="/">
|
||||
<ie5:apply-templates/>
|
||||
</ie5:template>
|
||||
|
||||
<ie5:template match="head|h:head"/>
|
||||
|
||||
<ie5:template match="text()">
|
||||
<ie5:value-of select="."/>
|
||||
</ie5:template>
|
||||
|
||||
<ie5:template match="*|@*">
|
||||
<ie5:copy>
|
||||
<ie5:apply-templates select="*|text()|@*"/>
|
||||
</ie5:copy>
|
||||
</ie5:template>
|
||||
|
||||
|
||||
<ie5:template match="mml:*">
|
||||
<ie5:eval no-entities="t" doc:id="eval">'<mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1)</ie5:eval>
|
||||
<ie5:for-each select="@*">
|
||||
<ie5:eval no-entities="t">' ' + this.nodeName</ie5:eval>="<ie5:value-of select="."/>"
|
||||
</ie5:for-each>
|
||||
<ie5:eval no-entities="t">'>'</ie5:eval>
|
||||
<ie5:apply-templates select="*|text()"/>
|
||||
<ie5:eval no-entities="t">'</mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '>'</ie5:eval>
|
||||
</ie5:template>
|
||||
|
||||
|
||||
<ie5:template match="mml:math">
|
||||
<ie5:if expr="mpisinstalled()=='false'">
|
||||
<embed type="text/mathml" height="75" width="300">
|
||||
<ie5:attribute name="mmldata">
|
||||
<ie5:eval doc:id="eval" no-entities="t">'<math>'</ie5:eval>
|
||||
<ie5:apply-templates/>
|
||||
<ie5:eval doc:id="eval" no-entities="t">'</math>'</ie5:eval>
|
||||
</ie5:attribute>
|
||||
</embed>
|
||||
</ie5:if>
|
||||
<ie5:if expr="mpisinstalled()=='true'">
|
||||
<ie5:eval doc:id="eval" no-entities="t">'<mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1)</ie5:eval>
|
||||
<ie5:for-each select="@*">
|
||||
<ie5:eval no-entities="t">' ' + this.nodeName</ie5:eval>="<ie5:value-of select="."/>"
|
||||
</ie5:for-each>
|
||||
<ie5:eval no-entities="t">'>'</ie5:eval>
|
||||
<ie5:apply-templates select="*|text()"/>
|
||||
<ie5:eval no-entities="t">'</mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '>'</ie5:eval>
|
||||
</ie5:if>
|
||||
</ie5:template>
|
||||
|
||||
<ie5:template match="html|h:html">
|
||||
<html xmlns:mml="http://www.w3.org/1998/Math/MathML">
|
||||
<head>
|
||||
<ie5:if expr="mpisinstalled()=='true'">
|
||||
<object id="mmlFactory"
|
||||
classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
|
||||
</object>
|
||||
<ie5:pi name="IMPORT">
|
||||
namespace="mml" implementation="#mmlFactory"
|
||||
</ie5:pi>
|
||||
</ie5:if>
|
||||
<ie5:apply-templates select="h:head/*|head/*"/>
|
||||
</head>
|
||||
<body>
|
||||
<ie5:apply-templates select="body|h:body"/>
|
||||
</body>
|
||||
</html>
|
||||
</ie5:template>
|
||||
|
||||
</ie5:apply-templates>
|
||||
|
||||
|
||||
</ie5:if>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -1,872 +0,0 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!--
|
||||
Presentation MathML Stylesheet
|
||||
-->
|
||||
|
||||
<!--
|
||||
$Id: pmathmlcss.xsl,v 1.1 2002/03/20 12:20:57 mf Exp $
|
||||
|
||||
Copyright David Carlisle 2001, 2002.
|
||||
|
||||
Use and distribution of this code are permitted under the terms of the <a
|
||||
href="http://www.w3.org/Consortium/Legal/copyright-software-19980720"
|
||||
>W3C Software Notice and License</a>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet
|
||||
version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns:m="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:doc="http://www.dcarlisle.demon.co.uk/xsldoc"
|
||||
xmlns:x="data:,x"
|
||||
exclude-result-prefixes="x h doc"
|
||||
>
|
||||
|
||||
<h:h2>Dictionary</h:h2>
|
||||
|
||||
<h:p> The following elements in the x: namespace form an
|
||||
implementation of an "Operator Dictionary" for this MathML
|
||||
Implementation. In the case of stretch operators, the element
|
||||
specifies the symbol parts via the latin-1 equivalent character based
|
||||
on the encoding in the symbol font. It is a clear "failure to comply
|
||||
to the spec" that using latin 1 characters (or numeric character
|
||||
references) in the latin 1 range access glyphs in teh symbol font via
|
||||
font position, however most of these character parts are not in
|
||||
Unicode (until 3.2), so there is no standard way to access these characters.</h:p>
|
||||
|
||||
<x:x x="{" m="0em" stretch="true" top="ì" middle="í" extend="ï" bottom="î">{</x:x>
|
||||
<x:x x="}" m="0em" stretch="true" top="ü" middle="ý" extend="ú" bottom="þ">{</x:x>
|
||||
|
||||
<x:x x="(" m="0em" stretch="true" top="æ" middle="ç" extend="ç" bottom="è">(</x:x>
|
||||
<x:x x=")" m="0em" stretch="true" top="ö" middle="÷" extend="÷" bottom="ø">)</x:x>
|
||||
|
||||
<x:x x="[" m="0em" stretch="true" top="é" middle="ê" extend="ê" bottom="ë">[</x:x>
|
||||
<x:x x="]" m="0em" stretch="true" top="ù" middle="ú" extend="ú" bottom="û">]</x:x>
|
||||
|
||||
<x:x x="〚" m="0em" stretch="true" top="éé" middle="êê" extend="êê" bottom="ëë">[[</x:x>
|
||||
<x:x x="〛" m="0em" stretch="true" top="ùù" middle="úú" extend="úú" bottom="ûû">]]</x:x>
|
||||
|
||||
<x:x x="|" m="0em" stretch="true" top="ç" middle="ç" extend="ç" bottom="ç">|</x:x>
|
||||
<x:x x="||" m="0em" stretch="true" top="çç" middle="çç" extend="çç" bottom="çç">||</x:x>
|
||||
|
||||
<x:x x="⁡" m="0em"></x:x><!-- applyfunction -->
|
||||
<x:x x="⁢" m="0em"></x:x><!-- invisibletimes -->
|
||||
<x:x x="-">−</x:x>
|
||||
<x:x x="≃"><span style="position:
|
||||
relative; top: +.1em;">−</span><span style="position:
|
||||
relative; left: -.55em; top: -.2em; margin: 0em;">~</span></x:x>
|
||||
<x:x x="︸" m="0em">_v_</x:x>
|
||||
|
||||
|
||||
<h:p>Remove these for now, as XML parser in IE6 is broken and doesn't
|
||||
accept plane 1 characters.</h:p>
|
||||
<!--
|
||||
<x:x x="𝔸" v="doublestruck">A</x:x>
|
||||
<x:x x="𝔹" v="doublestruck">B</x:x>
|
||||
<x:x x="ℂ" v="doublestruck">C</x:x>
|
||||
<x:x x="𝔻" v="doublestruck">D</x:x>
|
||||
|
||||
<x:x x="𝕒" v="doublestruck">a</x:x>
|
||||
<x:x x="𝕓" v="doublestruck">b</x:x>
|
||||
<x:x x="𝕔" v="doublestruck">c</x:x>
|
||||
<x:x x="𝕕" v="doublestruck">d</x:x>
|
||||
|
||||
<x:x x="𝔄" v="fraktur">A</x:x>
|
||||
<x:x x="𝔅" v="fraktur">B</x:x>
|
||||
<x:x x="ℭ" v="fraktur">C</x:x>
|
||||
<x:x x="𝔇" v="fraktur">D</x:x>
|
||||
|
||||
<x:x x="𝔞" v="fraktur">a</x:x>
|
||||
<x:x x="𝔟" v="fraktur">b</x:x>
|
||||
<x:x x="𝔠" v="fraktur">c</x:x>
|
||||
<x:x x="𝔡" v="fraktur">d</x:x>
|
||||
-->
|
||||
|
||||
<h:p>Grab all of the above into a variable.</h:p>
|
||||
<xsl:variable name="opdict" select="document('')/*/x:x"/>
|
||||
|
||||
<h:h2>HTML elements</h:h2>
|
||||
|
||||
<h:p>
|
||||
XHTML elements get passed straight through, sans namespace prefix.
|
||||
</h:p>
|
||||
<xsl:template match="h:*">
|
||||
<xsl:element name="{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
|
||||
<h:p>
|
||||
Template for the head element copies the original content, aand in
|
||||
addition adds a script element and CSS style element that implement
|
||||
the core of the MathML renderer.
|
||||
</h:p>
|
||||
|
||||
<h:p doc:ref="malign">
|
||||
The malign function first finds the left most item in the aligngroup, and
|
||||
then modifies the left margin of each item to make them
|
||||
align. (Currently only left alignment is supported.)
|
||||
</h:p>
|
||||
|
||||
<h:p doc:ref="mrowStretch">
|
||||
The mrowStretch function implements stretchy brackets. It is called
|
||||
repeatedly, once for each mo child,after a span corresponding to an
|
||||
mrow. The arguments are the id of teh span and the characters to use
|
||||
for the parts of the stretch operator.
|
||||
constructed fence. The
|
||||
</h:p>
|
||||
|
||||
<h:p doc:ref="css">
|
||||
Inline CSS style block handles all font and size specification for the
|
||||
various MathML operators.
|
||||
</h:p>
|
||||
|
||||
<xsl:template match="h:head">
|
||||
|
||||
<xsl:element name="{local-name(.)}">
|
||||
<xsl:copy-of select="@*"/>
|
||||
<xsl:apply-templates/>
|
||||
|
||||
<script>
|
||||
|
||||
<xsl:text doc:id="malign">
|
||||
function malign (l)
|
||||
{
|
||||
var m = 0;
|
||||
for ( i = 0; i < l.length ; i++)
|
||||
{
|
||||
m = Math.max(m,l[i].offsetLeft);
|
||||
}
|
||||
for ( i = 0; i < l.length ; i++)
|
||||
{
|
||||
l[i].style.marginLeft=m - l[i].offsetLeft;
|
||||
}
|
||||
}
|
||||
</xsl:text>
|
||||
|
||||
<xsl:text doc:id="mrowStretch">
|
||||
function mrowStretch (opid,opt,ope,opm,opb){
|
||||
opH = opid.offsetHeight;
|
||||
var opH;
|
||||
var i;
|
||||
var es;
|
||||
if (mrowH > opH * 2) {
|
||||
m= "<font size='+1' face='symbol'>" + opm + "</font><br/>" ;
|
||||
if ((mrowH < opH * 3) &&(opm == ope) ) m="";
|
||||
es="";
|
||||
for ( i = 3; i <= mrowH / (2*opH) ; i += 1) es += "<font size='+1' face='symbol'>" + ope + "</font><br/>" ;
|
||||
opid.innerHTML="<table class='lr'><tr><td><font size='+1' face='symbol'>" +
|
||||
opt + "</font><br/>" +
|
||||
es +
|
||||
m +
|
||||
es +
|
||||
"<font size='+1' face='symbol'>" + opb + "</font></td></tr></table>";
|
||||
}
|
||||
}
|
||||
</xsl:text>
|
||||
|
||||
<xsl:text doc:id="msubsup">
|
||||
function msubsup (bs,bbs,x,b,p){
|
||||
<!--
|
||||
p.style.setExpression("top",bs +" .offsetTop - " + (p.offsetHeight/2 +(bbs.offsetHeight - Math.max(bbs.offsetHeight, b.offsetHeight + p.offsetHeight)*.5)));
|
||||
-->
|
||||
p.style.setExpression("top",bs +" .offsetTop -" + (p.offsetHeight/2));
|
||||
b.style.setExpression("top",bs + ".offsetTop + " + (bbs.offsetHeight - b.offsetHeight*.5));
|
||||
x.style.setExpression("marginLeft",Math.max(p.offsetWidth,b.offsetWidth));
|
||||
document.recalc(true);
|
||||
}
|
||||
</xsl:text>
|
||||
|
||||
<!--
|
||||
function msubsupzz (bs,x,b,p){
|
||||
p.style.setExpression("top",bs +" .offsetTop - " + bs +
|
||||
"p.offsetHeight/2 +(" + bs + ".offsetHeight - Math.max(" + bs + ".offsetHeight, (" + bs + "b.offsetHeight + " + bs + "p.offsetHeight)*.5))");
|
||||
b.style.setExpression("top",bs + ".offsetTop + " + bs + ".offsetHeight - " + bs + "b.offsetHeight/2");
|
||||
x.style.setExpression("marginLeft","Math.max(" + bs +"p.offsetWidth,"
|
||||
+ bs +"b.offsetWidth)");
|
||||
}
|
||||
-->
|
||||
|
||||
<xsl:text doc:id="msup">
|
||||
function msup (bs,x,p){
|
||||
p.style.setExpression("top",bs +" .offsetTop -" + (p.offsetHeight/2));
|
||||
x.style.setExpression("marginLeft", bs +"p.offsetWidth");
|
||||
x.style.setExpression("height", bs + ".offsetHeight + " + p.offsetHeight);
|
||||
document.recalc(true);
|
||||
}
|
||||
</xsl:text>
|
||||
|
||||
<xsl:text doc:id="msub">
|
||||
function msub (bs,x,p){
|
||||
p.style.setExpression("top",bs +" .offsetTop +" + (p.offsetHeight/2));
|
||||
x.style.setExpression("marginLeft", bs +"p.offsetWidth");
|
||||
x.style.setExpression("height", bs + ".offsetHeight + " + p.offsetHeight);
|
||||
document.recalc(true);
|
||||
}
|
||||
</xsl:text>
|
||||
|
||||
<xsl:text doc:id="toggle">
|
||||
function toggle (x) {
|
||||
for ( i = 0 ; i < x.childNodes.length ; i++) {
|
||||
if (x.childNodes.item(i).style.display=='inline') {
|
||||
x.childNodes.item(i).style.display='none';
|
||||
if ( i+1 == x.childNodes.length) {
|
||||
x.childNodes.item(0).style.display='inline';
|
||||
} else {
|
||||
x.childNodes.item(i+1).style.display='inline';
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
</xsl:text>
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
<xsl:text doc:id="css">
|
||||
|
||||
.msubsup {
|
||||
<!--background-color: red;-->
|
||||
font-size: 80%;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.munderover {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.lr {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.mi {
|
||||
font-style: serif;
|
||||
}
|
||||
|
||||
|
||||
.mspace{
|
||||
display: inline;
|
||||
}
|
||||
.mtext {
|
||||
font-style: serif;
|
||||
}
|
||||
.ms {
|
||||
font-style: monospace;
|
||||
}
|
||||
|
||||
.mi1 {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.doublestruck {
|
||||
font-family: castellar, algerian,niagara engraved;
|
||||
}
|
||||
.mo {
|
||||
padding-right: .3em;
|
||||
padding-left: .3em;
|
||||
}
|
||||
|
||||
.mn {
|
||||
}
|
||||
|
||||
.msqrt {
|
||||
border-style: solid;
|
||||
border-color: black;
|
||||
border-width: .1em 0pt 0pt .1em;
|
||||
padding-left: .2em;
|
||||
margin-left: 0em;
|
||||
margin-top: .2em;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.actuarial {
|
||||
border-style: solid;
|
||||
border-color: black;
|
||||
border-width: .1em .1em 0pt 0pt ;
|
||||
padding-right: .2em;
|
||||
margin-right: 0em;
|
||||
margin-top: .2em;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.ssa {
|
||||
position:relative; top:+0.5ex;
|
||||
width: 0pt;
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
||||
.mover {
|
||||
margin: 0pt;
|
||||
padding: 0pt;
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mtable {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
.mfrac {
|
||||
text-align: center;
|
||||
display:inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.mfraca {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.mfracaa {
|
||||
border-width: 0em 0em .2ex 0em ; border-style: solid;
|
||||
border-color: black;
|
||||
}
|
||||
|
||||
|
||||
.mfracb {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.merror{
|
||||
background-color: white ;
|
||||
border-style: solid;
|
||||
border-color: #FF0000;
|
||||
color: #FF0000;
|
||||
}
|
||||
.mphantom{
|
||||
visibility: hidden;
|
||||
}
|
||||
</xsl:text>
|
||||
</style>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>
|
||||
Unimplemented MathML elements get copied literally, in red, mainly as
|
||||
a debugging aid.
|
||||
</h:p>
|
||||
<xsl:template match="m:*">
|
||||
<span style="color: red;"><<xsl:value-of select="local-name(.)"/>></span>
|
||||
<xsl:apply-templates/>
|
||||
<span style="color: red;"></<xsl:value-of select="local-name(.)"/>></span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>
|
||||
mi: set default font based on string length, otherwise behaviour based
|
||||
on entries in the operator dictionary if one exists, or content is
|
||||
copied through to the output unchanged.
|
||||
</h:p>
|
||||
<xsl:template match="m:mi">
|
||||
<span class="mi">
|
||||
<xsl:if test="1=string-length(normalize-space(.))">
|
||||
<xsl:attribute name="class">mi1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="@mathvariant"/>
|
||||
<xsl:variable name="x" select="normalize-space(.)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$opdict[@x=$x and @v]">
|
||||
<xsl:attribute name="class"><xsl:value-of select="$opdict[@x=$x]/@v"/></xsl:attribute>
|
||||
<xsl:value-of select="$opdict[@x=$x and @v]"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$x"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>
|
||||
Handling of mathvariant attribute.
|
||||
The choice of font families here (currently) avoids math-specific
|
||||
fonts but does use several fionts coming with windows 9.x and/or
|
||||
office 2000.
|
||||
</h:p>
|
||||
<xsl:template match="@mathvariant[.='bold']">
|
||||
<xsl:attribute name="style">font-weight: bold; font-style: upright</xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="@mathvariant[.='bold-italic']">
|
||||
<xsl:attribute name="style">font-style: upright; font-weight: bold; font-style: italic;</xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="@mathvariant[.='italic']">
|
||||
<xsl:attribute name="style">font-style: italic; </xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="@mathvariant[.='monospace']">
|
||||
<xsl:attribute name="style">font-family: monospace; </xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@mathvariant[.='sans-serif']">
|
||||
<xsl:attribute name="style">font-family: sans-serif; </xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="@mathvariant[.='bold-sans-serif']">
|
||||
<xsl:attribute name="style">font-family: sans-serif; font-weight: bold; </xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@mathvariant[.='fraktur']">
|
||||
<xsl:attribute name="style">font-family: old english text mt</xsl:attribute>
|
||||
<xsl:attribute name="class"></xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@mathvariant[.='double-struck']">
|
||||
<xsl:attribute name="class">doublestruck</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="@mathvariant[.='script']">
|
||||
<xsl:attribute name="style">font-family: brush script mt italic</xsl:attribute>
|
||||
<xsl:attribute name="class"></xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<h:p>mo: Generate a unique ID so that a script at the end of any
|
||||
surrounding mrow may replace the conent by a suitably stretched
|
||||
operator if need be.</h:p>
|
||||
<xsl:template match="m:mo">
|
||||
<span id="{generate-id()}" class="mo">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>mn: a simple span</h:p>
|
||||
<xsl:template match="m:mn">
|
||||
<span class="mn">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>munder: currently only supports underline, with a bottom border</h:p>
|
||||
<xsl:template match="m:munder">
|
||||
<span class="munder">
|
||||
<xsl:if test="normalize-space(*[2])='̲'">
|
||||
<xsl:attribute
|
||||
name="style">border-width: 0pt 0pt .1em 0pt; border-style: solid;"</xsl:attribute>
|
||||
</xsl:if>
|
||||
<span><xsl:apply-templates select="*[1]"/></span>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>mover: currently only supports overline, with a top border</h:p>
|
||||
<xsl:template match="m:mover">
|
||||
<span class="munder">
|
||||
<xsl:if test="normalize-space(*[2])='¯'">
|
||||
<xsl:attribute
|
||||
name="style">border-width: .1em 0pt 0pt 0pt; border-style: solid;"</xsl:attribute>
|
||||
</xsl:if>
|
||||
<span><xsl:apply-templates select="*[1]"/></span>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>munderover: </h:p>
|
||||
<xsl:template match="m:munderover">
|
||||
<table class="munderover">
|
||||
<tr><td><xsl:apply-templates select="*[3]"/></td></tr>
|
||||
<tr><td><xsl:apply-templates select="*[1]"/></td></tr>
|
||||
<tr><td><xsl:apply-templates select="*[2]"/></td></tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>mtext: a simple span</h:p>
|
||||
<xsl:template match="m:mtext">
|
||||
<span class="mtext">
|
||||
<xsl:value-of select="normalize-space(.)"/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>mstyle: not many attributes currently supported</h:p>
|
||||
<xsl:template match="m:mstyle">
|
||||
<span>
|
||||
<xsl:attribute name="style">
|
||||
<xsl:if test="@color">color: <xsl:value-of select="@color"/>; </xsl:if>
|
||||
<xsl:if test="@background">background-color: <xsl:value-of select="@background"/>; </xsl:if>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<h:p>mglyph: Uses disable output escaping to construct a numeric
|
||||
character reference. Uses IE's non conforming behaviour of using this
|
||||
number to access the font encoding rather than unicode.</h:p>
|
||||
<xsl:template match="m:mglyph">
|
||||
<font face="{@fontfamily}"><xsl:value-of
|
||||
disable-output-escaping="yes" select="'&#'"/>
|
||||
<xsl:value-of select="@index"/>;<xsl:text/>
|
||||
</font>
|
||||
</xsl:template>
|
||||
|
||||
<h:p>ms: a simple span with left and right character added to the content.</h:p>
|
||||
<xsl:template match="m:ms">
|
||||
<span class="ms">
|
||||
<xsl:value-of select="@lquote"/><xsl:if test="not(@lquote)">"</xsl:if>
|
||||
<xsl:value-of select="normalize-space(.)"/>
|
||||
<xsl:value-of select="@rquote"/><xsl:if test="not(@rquote)">"</xsl:if>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:math">
|
||||
<xsl:call-template name="mrow"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template match="m:mfenced">
|
||||
<xsl:variable name="l">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@open"><xsl:value-of select="@open"/></xsl:when>
|
||||
<xsl:otherwise>(</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="r">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@close"><xsl:value-of select="@close"/></xsl:when>
|
||||
<xsl:otherwise>)</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="s">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@sep">
|
||||
<xsl:call-template name="text">
|
||||
<xsl:with-param name="x" select="@sep"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>,</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<span id="{generate-id()}L"><xsl:value-of select="$l"/></span>
|
||||
<span id="{generate-id()}M">
|
||||
<xsl:for-each select="*">
|
||||
<xsl:apply-templates select="."/>
|
||||
<xsl:if test="position() != last()"><span id="{generate-id()}X{position()}"><xsl:value-of select="$s"/></span></xsl:if>
|
||||
</xsl:for-each>
|
||||
</span>
|
||||
<span id="{generate-id()}R"><xsl:value-of select="$r"/></span>
|
||||
<script>
|
||||
|
||||
<xsl:if test="$s=$opdict[@stretch='true']/@x">
|
||||
<xsl:for-each select="*[position()<last()]">
|
||||
<xsl:variable name="opdictentry" select="$opdict[@x=$s]"/>
|
||||
mrowStretch(<xsl:value-of select="concat(generate-id(),'X',position())"/>,"<xsl:value-of
|
||||
select="$opdictentry/@top"/>","<xsl:value-of
|
||||
select="$opdictentry/@extend"/>","<xsl:value-of
|
||||
select="$opdictentry/@middle"/>","<xsl:value-of
|
||||
select="$opdictentry/@bottom"/>");</xsl:for-each>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:variable name="opdictentry" select="$opdict[@x=$l]"/>
|
||||
var mrowH = <xsl:value-of select="generate-id()"/>M.offsetHeight;
|
||||
mrowStretch(<xsl:value-of select="generate-id()"/>L,"<xsl:value-of
|
||||
select="$opdictentry/@top"/>","<xsl:value-of
|
||||
select="$opdictentry/@extend"/>","<xsl:value-of
|
||||
select="$opdictentry/@middle"/>","<xsl:value-of
|
||||
select="$opdictentry/@bottom"/>");<xsl:text/>
|
||||
|
||||
<xsl:variable name="opdictentry2" select="$opdict[@x=$r]"/>
|
||||
mrowStretch(<xsl:value-of select="generate-id()"/>R,"<xsl:value-of
|
||||
select="$opdictentry2/@top"/>","<xsl:value-of
|
||||
select="$opdictentry2/@extend"/>","<xsl:value-of
|
||||
select="$opdictentry2/@middle"/>","<xsl:value-of
|
||||
select="$opdictentry2/@bottom"/>");<xsl:text/>
|
||||
</script>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template match="m:mmultiscripts">
|
||||
<table style="display:inline; vertical-align: middle;">
|
||||
<tr>
|
||||
<xsl:for-each select="*[preceding-sibling::m:mprescripts and position() mod 2 = 0]">
|
||||
<td><xsl:apply-templates select="."/></td>
|
||||
</xsl:for-each>
|
||||
<td rowspan="2"><xsl:apply-templates select="*[1]"/></td>
|
||||
<xsl:for-each select="*[not(preceding-sibling::m:mprescripts) and position() !=1 and position() mod 2 = 1]">
|
||||
<td><xsl:apply-templates select="."/></td>
|
||||
</xsl:for-each>
|
||||
</tr>
|
||||
<tr>
|
||||
<xsl:for-each select="*[preceding-sibling::m:mprescripts and position() mod 2 = 1]">
|
||||
<td><xsl:apply-templates select="."/></td>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="*[not(preceding-sibling::m:mprescripts) and
|
||||
not(self::m:mprescripts) and position() mod 2 = 0]">
|
||||
<td><xsl:apply-templates select="."/></td>
|
||||
</xsl:for-each>
|
||||
</tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:none"></xsl:template>
|
||||
|
||||
<xsl:template match="m:merror">
|
||||
<span class="merror"><xsl:call-template name="mrow"/></span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:mphantom">
|
||||
<span class="mphantom"><xsl:apply-templates/></span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:maction[@type='tooltip']">
|
||||
<span title="{*[2]}"><xsl:apply-templates select="*[1]"/></span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:maction[@type='toggle']">
|
||||
<span id="{generate-id()}" onclick="toggle({generate-id()})">
|
||||
<span style="display:inline;"><xsl:apply-templates select="*[1]"/></span>
|
||||
<xsl:for-each select="*[position() > 1]">
|
||||
<span style="display:none;"><xsl:apply-templates select="."/></span>
|
||||
</xsl:for-each>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:maction[@type='statusline']">
|
||||
<span id="{generate-id()}"
|
||||
onmouseover="window.status='{*[2]}';"
|
||||
onmouseout="window.status='';"
|
||||
>
|
||||
<xsl:apply-templates select="*[1]"/></span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:maction[@type='highlight']">
|
||||
<span id="{generate-id()}"
|
||||
onmouseover="{generate-id()}.style.backgroundColor='yellow';"
|
||||
onmouseout="{generate-id()}.style.backgroundColor='white';"><xsl:apply-templates/></span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template match="m:mrow" name="mrow">
|
||||
<span id="{generate-id()}" class="mrow">
|
||||
<xsl:apply-templates select="*"/>
|
||||
</span>
|
||||
<xsl:if test="m:mo[@stretch='true' or normalize-space(.)=$opdict[@stretch='true']/@x]">
|
||||
<script>
|
||||
var mrowH = <xsl:value-of select="generate-id()"/>.offsetHeight;
|
||||
<xsl:for-each select="m:mo[@stretch='true' or
|
||||
normalize-space(.)=$opdict[@stretch='true']/@x]">
|
||||
|
||||
<xsl:variable name="o" select="normalize-space(.)"/>
|
||||
<xsl:variable name="opdictentry" select="$opdict[@x=$o]"/>
|
||||
mrowStretch(<xsl:value-of select="generate-id()"/>,"<xsl:value-of
|
||||
select="$opdictentry/@top"/>","<xsl:value-of
|
||||
select="$opdictentry/@extend"/>","<xsl:value-of
|
||||
select="$opdictentry/@middle"/>","<xsl:value-of
|
||||
select="$opdictentry/@bottom"/>");</xsl:for-each>
|
||||
</script>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:msubsup">
|
||||
<span id="{generate-id()}" >
|
||||
<xsl:apply-templates select="*[1]"/></span
|
||||
><span id="{generate-id()}b" class="msubsup"><xsl:apply-templates
|
||||
select="*[2]"/></span
|
||||
><span id="{generate-id()}p" class="msubsup"><xsl:apply-templates
|
||||
select="*[3]"/></span
|
||||
><span id="{generate-id()}x"></span>
|
||||
<script>
|
||||
msubsup("<xsl:value-of select="concat(generate-id(),'",',generate-id(),',',generate-id(),'x,',generate-id(),'b,',generate-id())"/>p);
|
||||
</script>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="h:table//m:msubsup|m:mtable//m:msubsup|m:msubsup"
|
||||
priority="2">
|
||||
<span>
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span
|
||||
><sub><xsl:apply-templates
|
||||
select="*[2]"/></sub>
|
||||
<sup><xsl:apply-templates
|
||||
select="*[3]"/></sup>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:msup
|
||||
">
|
||||
<span id="{generate-id()}">
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span
|
||||
><span id="{generate-id()}p" class="msubsup"><xsl:apply-templates
|
||||
select="*[2]"/></span
|
||||
><span id="{generate-id()}x"></span>
|
||||
<script>
|
||||
msup("<xsl:value-of select="concat(generate-id(),'",',generate-id(),'x,',generate-id())"/>p);
|
||||
</script>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="h:table//m:msup|m:mtable//m:msup|m:msup"
|
||||
priority="2">
|
||||
<span>
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span
|
||||
><sup><xsl:apply-templates
|
||||
select="*[2]"/></sup>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:msub
|
||||
">
|
||||
<span id="{generate-id()}">
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span
|
||||
><span id="{generate-id()}p" class="msubsup"><xsl:apply-templates
|
||||
select="*[2]"/></span
|
||||
><span id="{generate-id()}x"></span>
|
||||
<script>
|
||||
msub("<xsl:value-of select="concat(generate-id(),'",',generate-id(),'x,',generate-id())"/>p);
|
||||
</script>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="h:table//m:msub|m:mtable//m:msub|m:msub"
|
||||
priority="2">
|
||||
<span>
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span
|
||||
><sub><xsl:apply-templates
|
||||
select="*[2]"/></sub>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:*/text()" name="text">
|
||||
<xsl:param name="x" select="normalize-space(.)"/>
|
||||
<xsl:variable name="mo" select="document('')/*/x:x[@x=$x]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$mo"><xsl:copy-of select="$mo/node()"/></xsl:when>
|
||||
<xsl:otherwise><xsl:copy-of select="$x"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:msqrt">
|
||||
<span class="msqrtx">\</span><span class="msqrt">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:menclose[@notation='radical']">
|
||||
<span class="msqrtx">\</span><span class="msqrt">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:menclose[@notation='actuarial']">
|
||||
<span class="actuarial">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:menclose">
|
||||
<span class="msqrt">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:mroot">
|
||||
<span class="msqrtx"><sup><xsl:apply-templates select="*[2]"/></sup>\</span><span class="msqrt">
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:mfrac">
|
||||
<xsl:param name="full" select="not(ancestor::m:mfrac)"/>
|
||||
<table class="mfrac">
|
||||
<xsl:if test="$full">
|
||||
<xsl:attribute name="style">font-size: 75% ;</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="not($full)">
|
||||
<xsl:attribute name="style">font-size: 100% ;</xsl:attribute>
|
||||
</xsl:if>
|
||||
<tr id="a{generate-id()}" class="mfraca"><td class="mfracaa">
|
||||
<xsl:apply-templates select="*[1]"/>
|
||||
</td></tr>
|
||||
<tr id="b{generate-id()}" class="mfracb"><td>
|
||||
<xsl:apply-templates select="*[2]"/>
|
||||
</td></tr>
|
||||
</table><xsl:if test="$full"><script>
|
||||
if ( a<xsl:value-of select="generate-id()"
|
||||
/>.offsetHeight > b<xsl:value-of select="generate-id()"
|
||||
/>.offsetHeight ) b<xsl:value-of select="generate-id()
|
||||
"/>.style.setExpression("height",a<xsl:value-of select="generate-id()"/>.offsetHeight );
|
||||
else a<xsl:value-of
|
||||
select="generate-id()"/>.style.setExpression("height",b<xsl:value-of
|
||||
select="generate-id()"/>.offsetHeight );
|
||||
</script></xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:padded">
|
||||
<span>
|
||||
<xsl:attribute name="display">
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:mspace">
|
||||
<span style="padding-left: {@width};"></span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:mtable">
|
||||
<table class="mtable">
|
||||
<xsl:apply-templates/>
|
||||
</table>
|
||||
<script>
|
||||
<xsl:variable name="t" select="."/>
|
||||
<xsl:for-each select="m:mtr[1]/m:mtd">
|
||||
<xsl:variable name="c" select="position()"/>
|
||||
<xsl:for-each select="descendant::m:maligngroup">
|
||||
<xsl:variable name="g" select="position()"/>
|
||||
malign([<xsl:for-each
|
||||
select="$t/m:mtr/m:mtd[$c]/descendant::m:maligngroup[$g]">
|
||||
<xsl:value-of select="generate-id()"/>
|
||||
<xsl:if test="position()<last()">,</xsl:if>
|
||||
</xsl:for-each>]);</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</script>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:mtr">
|
||||
<tr>
|
||||
<xsl:apply-templates/>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="m:mtd">
|
||||
<td>
|
||||
<xsl:apply-templates/>
|
||||
</td>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="m:maligngroup">
|
||||
<xsl:variable name="g">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@groupalign">
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::td/@groupalign">
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::tr/@groupalign">
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::table/@groupalign">
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>left</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<span id="{generate-id()}"></span>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Add table
Add a link
Reference in a new issue