我正在尝试从内容mathml中创建数学符号或中缀表达式,
我正在为此ctop.xsl
提供帮助:
/***ctop.xsl**/
可以解析它以获得如下表达式:
<html>
<head>
<script>
function loadXMLDoc(filename)
{
if (window.ActiveXObject)
{
xhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
else
{
xhttp = new XMLHttpRequest();
}
xhttp.open("GET", filename, false);
try {xhttp.responseType = "msxml-document"} catch(err) {} // Helping IE11
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml = loadXMLDoc("contentmathml.xml");
xsl = loadXMLDoc("ctop.xsl");
// code for IE
if (window.ActiveXObject || xhttp.responseType == "msxml-document")
{
ex = xml.transformNode(xsl);
document.getElementById("example").innerHTML = ex;
}
// code for Chrome, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml, document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onload="displayResult()">
<div id="example" />
</body>
</html>
此处 contentmathml.xml 是我的输入
我的内容mathml为:
输入:
<math><apply><power></power><ci>x</ci><cn>2</cn></apply></math>
我得到输出:x2
预期:x ^ 2
我再次尝试输入:
<math><apply><sin></sin><ci>x</ci></apply></math>
输出:sinx 预期输出:sin(x)'
如何以这种方式更改 ctop.xsl 以将中缀作为输出?