LINQ to XML 是否会忽略 DTD 中的包含内容?
我正在使用 MathML DTD 使用 System.Xml.Linq 解析 MathML。虽然普通的 MathML 内容可以很好地识别,但是 DTD 中包含的 MMLEXTRA 会被忽略,并且我出现错误。这是我正在使用的代码:
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()
。任何帮助表示赞赏!
I'm using the MathML DTD for parsing MathML using System.Xml.Linq.
While the ordinary MathML stuff gets recognized fine, the MMLEXTRA
include in the DTD gets ignored and I get errors. Here's the code I'm using:
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;
}
}
The parser simply does XDocument.Load()
. Any help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论