] [XML DTD constraint Profile

1. What is XML?

  • XML refers to extensible markup language (EXtensible Markup Language)
  • XML is a markup language, much like HTML
  • XML is designed to transmit data rather than displaying data
  • XML tags are not predefined. You need to define your own labels.
  • XML is designed to be self-descriptive.
  • XML is a W3C Recommendation

2. What is the format of a good XML?

2.1 has one and only one root element

<?xml version="1.0" encoding="UTF-8"?>
<persons>
	<person pid="p1" sex="男" qq="aaa" parent="p2">
		<name>张小明</name>
		<age>10</age>
		<contact>
			<phone>1234567</phone>
		</contact>
		<br/>
	</person>
	<person pid="p2">
		<name>张大明</name>
		<age>35</age>
		<contact>
			<email>123@qq.com</email>
		</contact>
	</person>
</persons>

Which persons is one and only one root element.

2.2 XML tags to distinguish the correct case
Here Insert Picture Description
FIG XML tags as given case sensitive shown perSons.

2.3 nested tags correctly
Here Insert Picture Description
2.4 legitimate tag name
Here Insert Picture Description
2.5 valid attribute defined
Here Insert Picture Description

3, adding the XML DTD declaration

Here Insert Picture Description

<!DOCTYPE root[]>
//root指的是当前判断的根元素

4, the syntax element defines

<!ELEMENT element-name (type)>
   注:根标签也要定义!!!

5, the classification of elements

Here Insert Picture Description

 <!ELEMENT element-name EMPTY>//空元素
 <!ELEMENT element-name (#PCDATA)>//文本元素
 <!ELEMENT element-name (e1,e2)>//混合元素

6, attribute defined grammar

Here Insert Picture Description

 <!ATTLIST element-name 
     att_name type
   >
   attribute
    ID 
   (|)
   CDATA 
   IDREF
   reference

7, XML is a special symbol

&(逻辑与)  &amp;        
<(小于)    &lt;        
>(大于)    &gt;        
"(双引号)  &quot;      
'(单引号)  &apos;

8, case expansion

Case a legal XML

Case II of DTD elements limit

Case III DTD restrictions on property

Four cases of DTD config.xml restrictions

servlet tag error analysis Case 5 web.xml file

Guess you like

Origin blog.csdn.net/zyp_baoku/article/details/90485676
DTD