我正在使用 MathML DTD 来解析 MathMLSystem.Xml.Linq.
虽然普通的 MathML 东西被很好地识别,MMLEXTRA
但 DTD 中的包含被忽略并且我得到错误。这是我正在使用的代码:
if (!string.IsNullOrWhiteSpace(mathML))
{
try
{
const string preamble =
"<!DOCTYPE mml:math PUBLIC \"-//W3C//DTD MathML 2.0//EN\"\n" +
"\"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd\" [\n" +
"<!ENTITY % MATHML.prefixed \"INCLUDE\">\n" +
"<!ENTITY % MATHML.prefix \"mml\"> \n" +
"]>";
var parsed = Parser.Parse(preamble + Environment.NewLine + mathML);
textEditor.Text = printed;
lblStatus.Caption = "MathML successfully translated.";
}
catch (Exception e)
{
lblStatus.Caption = "Cannot translate text. " + e.Message;
}
}
解析器只是这样做XDocument.Load()
。任何帮助表示赞赏!