XML实体 - 我的代码有什么问题?
问题描述:
我正在参加一门XML课程,我必须通读这本名为“INeasysteps”的书。我试图按照教程的一个关于“添加注释和实体”,但是当我把它在浏览器中我不断收到回应:XML实体 - 我的代码有什么问题?
Blockquote XML Parsing Error: undefined entity Line Number 11, Column 13: Blockquote
这里是我的代码:请让我知道我做错了。仅供参考,有在JEDIT分析器没有错误,但我得到的,当我把我的XML代码在浏览器上面的错误:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- XML in easy steps - Page 40. -->
<?xml-stylesheet
type = "text/css" href = "history.css" ?>
<!DOCTYPE doc SYSTEM "history.dtd" >
<doc>
<para>Both &html; and &xml; are derived from &sgml; which is, in turn, a descendant of the &gml; that was developed in the 1960s by IBM. </para>
</doc>
这里是history.dtd文件
<!-- Define the root element. -->
<!-- May contain one child element called para. -->
<!ELEMENT doc (para)>
<!-- Define the child element. -->
<!-- May contain Parsed Character Data. -->
<!ELEMENT para (#PCDATA)>
<!-- Define entity values. -->
<!-- Common markup language acronyms. -->
<!ENTITY html
"HyperText Markup Language (HTML)" >
<!ENTITY xml
"eXtensible Markup Language (XML)" >
<!ENTITY sgml
"Standard Generalized Markup Language (SGML)" >
<!ENTITY gml
"Generalized Markup Language (GML)" >
答
大多数浏览器不会加载外部实体。如果你想打开一个浏览器和实体的XML文件来妥善解决,(在DOCTYPE声明[
和]
之间)添加实体声明到内部子集:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- XML in easy steps - Page 40. -->
<?xml-stylesheet type="text/css" href = "history.css" ?>
<!DOCTYPE doc SYSTEM "history.dtd" [
<!ENTITY html "HyperText Markup Language (HTML)" >
<!ENTITY xml "eXtensible Markup Language (XML)" >
<!ENTITY sgml "Standard Generalized Markup Language (SGML)" >
<!ENTITY gml "Generalized Markup Language (GML)" >
]>
<doc>
<para>Both &html; and &xml; are derived from &sgml; which is, in turn, a
descendant of the &gml; that was developed in the 1960s by IBM. </para>
</doc>
得到它,所以我只需要使用[]将dtd文件添加到xml文件中。谢谢 –