在Firefox:如何包含HTML實體到XML文件
<?xml version="1.0" encoding="utf-8"?>
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mi>ρ</mi>
</math>
導致 「未定義實體」 的錯誤。
我知道那裏缺少一些東西。我只是不知道該怎麼寫才能糾正這個問題。我想避免在文檔中重寫每一個unicode字符。
編輯我嘗試以下,仍然沒有工作,同樣的錯誤:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE math [
<!ENTITY % HTMLlat1 PUBLIC
"-//W3C//ENTITIES Latin 1 for XHTML//EN"
"xhtml-lat1.ent">
%HTMLlat1;
<!ENTITY % HTMLsymbol PUBLIC
"-//W3C//ENTITIES Symbols for XHTML//EN"
"xhtml-symbol.ent">
%HTMLsymbol;
<!ENTITY % HTMLspecial PUBLIC
"-//W3C//ENTITIES Special for XHTML//EN"
"xhtml-special.ent">
%HTMLspecial;
]>
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mi>ρ</mi>
</math>
編輯在Chrome中,這將導致以下消息:
error on line 6 at column 13: PEReference: %HTMLlat1; not found
warning on line 10 at column 15: PEReference: %HTMLsymbol; not found
warning on line 14 at column 16: PEReference: %HTMLspecial; not found
編輯嘗試下載.ent文件並將引用更改爲本地http://路徑或file:///路徑,但沒有成功。 類似的職位有關的主題:XML catalog in PHP
編輯的瀏覽器快速的解決方法:
<!DOCTYPE html>
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mi>ρ</mi>
</math>
您需要抑制XML頭,因此它被理解爲HTML。
不過,這並沒有回答問題,因爲問題是導入實體,而文檔被聲明爲XML。
ANSWER
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mi>ρ</mi>
</math>
我認爲(想!)命名實體僅在HTML定義。您可能需要數字或六進制等效 –