Sample analysis of XML document type declaration
This article mainly introduces the example analysis of XML document type declaration, which is very detailed and has certain reference value. Friends who are interested must finish it!
Because XML can customize tags, everyone defines a different set of tags, and applications cannot process XML documents without a set of standards that define the principles for defining tags. The solution to this problem is DTD,DTD (Document Type Definition, document type definition), which is used to define the writing rules of XML documents. Such as which elements can appear in the document, and the requirements of the content and attributes of the element, and so on. The application will use this DTD to verify the document, and the XML document that conforms to the DTD constraint rules is called a valid document, which can be processed in the next step, otherwise an error will be reported, and the application can catch the error for corresponding exception handling. The inspection process is optional, depending on the specific application.
Document type declaration
To use DTD for validation, specify the DTD using the document type definition declaration. Such as:
The Jims Jims@163.com Jims@21cn.com document type declaration is after the XML declaration and before the root element. If the dtd document is native, the path name can be used to directly indicate the location of the dtd document. The portal.dtd is as follows:
The above content can also be written directly to the XML document. This dtd declaration method is called internal dtd subset, such as:
] > 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 internal and external dtd to form a dtd to validate XML documents. Such as:
] > Note: when using internal and external dtd, the two dtd should be compatible with each other and there should be no conflicts.
The above is all the contents of the article "sample Analysis of XML document Type declarations". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!