XML document type declaration

Source: Internet
Author: User
Because XML can customize tags, the set of tags defined by each person is different. if there is no set of standards to define tags, the application cannot process XML documents. The solution to this problem uses DTD and DTD (DocumentTypeDefinition, Document Type Definition) to define the compiling rules of XML documents. Because XML can customize tags, the set of tags defined by each person is different. if there is no set of standards to define tags, the application cannot process XML documents. The solution to this problem uses DTD and DTD (Document Type Definition, Document Type Definition) to define the compiling rules of XML documents. For example, which elements can be included in the document and the requirements of the content and attributes of the elements. The application uses this DTD to verify the document. XML documents that comply with the DTD constraints are called valid documents. you can proceed with the next step. Otherwise, an error is reported, the application can capture the error and handle the exception accordingly. The inspection process is optional, depending on the specific application.

Document Type Declaration
To use DTD for validity verification, you must use the Document Type Definition declaration to specify the DTD. For example:

 
  
  
   Jims
   
  
   Jims@163.com
   
  
   Jims@21cn.com
  
 

The document type declaration is after the XML declaration and before the root element. If the dtd document is located on the local machine, the path name can be used to indicate the location of the document. The content of portal. dtd is as follows:

 
 
 

The above content can also be directly written into the XML document. This dtd declaration method is called the internal dtd subset, for example:

 
 
 ]>
  
  
   Jims
   
  
   Jims@163.com
   
  
   Jims@21cn.com
  
 

If the dtd is outside the XML document, it is called an external dtd subset. We can combine the internal and external dtd to form a dtd to verify the XML document. For example:

 
 ]>

Note: When using internal and external dtd, the two dtd must be compatible with each other and cannot conflict with each other.

The above is the detailed content of the XML document type declaration. For more information, see other related articles in the first PHP community!

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.