简体   繁体   English

XML外部ENTITY DTD的PEReference错误

[英]PEReference error with XML external ENTITY DTD

I have this XML code declaring an external DTD ENTITY: 我有此XML代码声明一个外部DTD实体:

<!DOCTYPE customers [
 <!ENTITY % itemCodes SYSTEM "codes.dtd">
 %itemCodes;
]>

This is simply to call up some pre-written codes from codes.dtd : 这仅仅是从code.dtd调用一些预先编写的代码:

<!ENTITY DCT5Z "Tapan Digital Camera 5 Mpx - zoom">
<!ENTITY SM128 "SmartMedia 128MB Card">
<!-- etc. -->

But I get this error: 但是我得到这个错误:

This page contains the following errors:

error on line 53 at column 8: PEReference: %itemCodes; not found

Why would that be? 为什么会这样呢?

Why would that be? 为什么会这样呢?

Because it can't find the codes.dtd file. 因为找不到codes.dtd文件。 If you aren't using some sort of catalog based resolution mechanism, then the codes.dtd would have to be in the working directory of the program you're running. 如果您不使用某种基于目录的解析机制,则codes.dtd必须位于您正在运行的程序的工作目录中。

But an error on line 53 seems odd. 但是第53行的错误似乎很奇怪。 That's too far into a file for a DTD. 对于DTD而言,这太过分了。 What does line 53 look like? 第53行是什么样子?

UPDATE : On reconsideration, the problem may not be that codes.dtd couldn't be found, but that the XML parser being used doesn't process external entities. 更新 :经过重新考虑,问题可能不在于codes.dtd ,而是所使用的XML解析器codes.dtd外部实体。 (After all, it said that the PE reference itself, and not its referent, couldn't be found.) This is a quite common limitation of non-validating parsers, but the error diagnostic could have been more helpful ("Sorry, external entity references are not supported".) (毕竟,它说找不到PE引用本身,而不是它的引用对象。)这是非验证解析器的一个很常见的局限性,但是错误诊断本来可以提供更大的帮助(“抱歉,外部不支持实体引用”。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM