Implementation Policy of external entity in xml dtd verification.

Source: Internet
Author: User
Tags net xml net xml parser parse error xml parser

In the implementation of XML parser, the implementation of DTD is quite troublesome. The trouble lies not in the logic of the DTD, but in how to process the external entity of the DTD, for example, the mutual calls between the DTD files.

For example, the following DTD declaration:

<! Entity imported-File System "imported-file">

% Imported-file;

In the above two DTD statements, a parameterized external entity is first declared, and then the external entity is referenced to import the DTD file as part of the entire DTD. So what should I do when XML Parser encounters such a DTD declaration?

One solution is not to parse the entity content, but simply as an external entity and pass it to the application.ProgramProcessing. This solution is the simplest. The problem is that the imported file is a logical part of the DTD, where element and ATTLIST may be declared. If this file is not parse, The DTD validate will fail.

The second solution is to try parse the external entity. OK. If the external entity indicates that it is indeed a DTD file, there is no problem, but if the object pointed to by the entity is only a simple text file, but it is not a valid DTD file, so errors may occur. This Parse error can be processed in real time, and several other problems should be prevented, such as circular references between files. The most troublesome thing is that users may not want to take the file corresponding to the entity as a part of the DTD. When the XML file does not comply with the DTD verification, and the file contains a correct DTD declaration, it may cause the invalidity of the DTD validate. This should have reported an error. Now it has become the correct XML file.

Of course, the correct method is to send a message to the user each time the external entity statement is found, and the user specifies a specific action. In this case, the interface is troublesome when XML parser is used. You must specify an entity action for parser before starting parse.

Take the XML file of OpenOffice as an example.. Net XML Parser and xerces C ++ for parse, without specifying any entity handler ,.. Net parser. xerces C ++ reports an error. The error is the Validation Part Of The DTD. It can be seen that the two parser have significant differences in the processing of the external DTD. In addition, xmlspy 2004 can also be properly verified.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.