我正在尝试从内容 mathml 中制作数学符号或中缀表达式,
我正在提供帮助ctop.xsl
为了这:
/***ctop.xsl**/
Refer
可以解析得到表达式如下:
<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>
Here 内容mathml.xml是我的输入
我的 mathml 内容为:
Input:
<math><apply><power></power><ci>x</ci><cn>2</cn></apply></math>
我越来越像输出:x2
预期:x^2
我再次尝试作为input:
<math><apply><sin></sin><ci>x</ci></apply></math>
输出:sinx
预期输出:sin(x)'
我怎样才能改变ctop.xsl以这种方式获取中缀作为输出?
您的输入不正确,它应该位于 MathML 命名空间中:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><power></power><ci>x</ci><cn>2</cn></apply>
</math>
与您的问题没有直接关系,但这里有一个更新的、维护的 ctop.xsl 样式表版本
https://github.com/davidcarlisle/web-xslt/tree/master/ctop
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)