저는 System.Xml.Linq를 사용하여 MathML을 파싱 할 때 MathML DTD를 사용하고 있습니다. 평범한 MathML 파일은 정상적으로 인식되지만 DTD에 포함 된 MMLEXTRA
은 무시되고 오류가 발생합니다. 다음은 내가 사용하고있는 코드입니다.LINQ to XML 무시는 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()
입니다. 어떤 도움을 주셔서 감사합니다! DTD의에서
에서 무엇입니까? –
@Kirk'Parser'는 기본적으로'XDocument.Load'를 수행하는 구성 요소 일뿐입니다. 이 호출은 모든 MathML 참조를 직접 해결하지만 가정하지는 않습니다. –