当前位置:网站首页>XML configuration file (DTD detailed explanation)
XML configuration file (DTD detailed explanation)
2022-07-05 23:49:00 【Customer bank】
Catalog
3. The classification of elements
3、 ... and . Attribute definitions
One .XML Introduce
1. What is? XML file ?
Extensible Markup Language( Extensible markup language ), abbreviation XML, Be similar to HTML, Used to transmit and store data .
What is extensible markup language ?
- In an electronic computer , A marker is a symbol of information that a computer can understand , By such a mark , Computers can process various kinds of information, such as articles, etc . for example :table label , After the browser parses , Generate a table .
2.XML Role of documents
- To hold data , And the data are self descriptive
- It can be used as the configuration file of the project or template
- Data that can be used to transmit data over the network ( But not much is used now , At present, they are all using JSON Mainly )
- XML Inside DTD Specifications can be defined , The function is equivalent to interface , That is, only by using this specification can we realize XML The function of
- In order to facilitate different applications 、 Data sharing and communication between different platforms .
3.XML Format
There is a root element ( The root element is like HTML Medium <html></html> The label is the same , All other labels are written in this label , All such tags can only have one )
- XML Labels are strictly case sensitive
- Use the end tag correctly , Have a beginning and an end (<html></html> It's like this, from beginning to end )
- Nesting labels correctly
- Use legal tag name
- Define valid properties
Two . Element definition
1. What is? DTD
- DTD The full name is Document Type Definition, Is a file definition format .
- DTD Specifies the XML The file structure is XML The file provides syntax and rules .
- stay DTD In the definition of XML File structure , And then according to DTD To write XML file . It's like function definition in programming language , When using a function, you should reference it according to the format of the function declaration .
PS: In short ,DTD It's used to constrain XML Document , Make it used under certain specifications , except DTD Outside technology , also Schema technology , Also for constraints XML Document .
2.DTD Statement statement
stay XML Add DTD Statement <!DOCTYPE root[]>,root----> Root element
for example :
The root element in this code is <persons></persons>, Then let's change the sentence to <!DOCTYPE persons[]>.
Then the code when we define the specification is written in DTD In a declaration statement .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[]>
<persons>
<person pid="p1" sex=" male " qq="aaa" parent="p2">
<name> Zhang Xiaoming </name>
<age>10</age>
<contact>
<phone>1234567</phone>
</contact>
<br/>
</person>
<person pid="p2">
<name> Zhang Daming </name>
<age>35</age>
<contact>
<email>[email protected]</email>
</contact>
</person>
</persons>
3. The classification of elements
3.1 <ELEMENT The element name EMPTY> Empty elements
What is an empty element ?
- Tags without content are called empty elements .
- because HTML The content of the element is the content between the start tag and the end tag . And some HTML Element has empty content .(empty content), Those with empty content HTML Elements , Is an empty element . Empty elements are closed in the start tag .
ps: I define a tag casually <abc/> This is an empty element , Our common html Some tags of are also empty elements , for example <br><hr><input> These are empty elements .
3.2 <ELEMENT The element name (#PCDATA)> Text elements
The so-called text element , That is, text data can be put into the label body
for example :
<name> Zhang Xiaoming </name>
3.3 <ELEMENT The element name (e1,e2)> Mixed elements
A mixed element means that there are other child elements under the element .
for example :
<persons><contact> There are many sub elements under the element
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE persons[ ]> <persons> <person pid="p1" sex=" male " qq="aaa" parent="p2"> <name> Zhang Xiaoming </name> <age>10</age> <contact> <phone>1234567</phone> </contact> <br/> </person> <person pid="p2"> <name> Zhang Daming </name> <age>35</age> <contact> <email>[email protected]</email> </contact> </person> </persons>
3.4. Element limits
- Element symbols
1. And ( ,)
2. Not ( | )
- The number of occurrences of the element
1. 0 or 1:?
2. 0-N: *
3. 1-N:+
Element defines code practice :
Have made detailed remarks , These are the contents just mentioned above
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)> <!--persons Yes 1-N individual person Elements -->
<!ELEMENT person (name,age,contact,br*)> <!--person There is... Under the element name,age,contact,br These sub elements -->
<!ELEMENT name (#PCDATA)> <!--name Is a text element -->
<!ELEMENT age (#PCDATA)> <!--age Is a text element -->
<!ELEMENT contact (phone|email*)> <!--contact There can be phone Element or email Elements -->
<!ELEMENT phone (#PCDATA)> <!--phone Is a text element -->
<!ELEMENT email (#PCDATA)> <!--email Is a text element -->
<!ELEMENT br EMPTY> <!--br Is an empty element -->
]>
<persons>
<person>
<name> Zhang Xiaoming </name>
<age>10</age>
<contact>
<phone>1234567</phone>
</contact>
<br/>
</person>
<person>
<name> Zhang Daming </name>
<age>35</age>
<contact>
<email>[email protected]</email>
</contact>
</person>
</persons>
3、 ... and . Attribute definitions
1. grammar
<!ATTLIST Element name The attribute name type describe >
2. Attribute types
- ID : Assign a id Number ,id No. cannot be repeated
- CDATA : The text type
- IDREF: Reference type , Enter the ID
- ( male | Woman ): Either male or female , You can also set other , such as 1|2, Either for 1 Either for 2
3. Property description
- #REQUIRED: Required
- #IMPLED: Not required
- " The default value is ", Only like ( male | Woman ) Type , Only by default can the description be used .
Attribute definition code practice
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)> <!--persons Yes 1-N individual person Elements -->
<!ELEMENT person (name,age,contact,br*)> <!--person There is... Under the element name,age,contact,br These sub elements -->
<!ELEMENT name (#PCDATA)> <!--name Is a text element -->
<!ELEMENT age (#PCDATA)> <!--age Is a text element -->
<!ELEMENT contact (phone|email*)> <!--contact There can be phone Element or email Elements -->
<!ELEMENT phone (#PCDATA)> <!--phone Is a text element -->
<!ELEMENT email (#PCDATA)> <!--email Is a text element -->
<!ELEMENT br EMPTY> <!--br Is an empty element -->
<!-- Attribute describes code practice -->
<!ATTLIST person
pid ID #REQUIRED
sex ( male | Woman ) " male "
qq CDATA #IMPLIED
parent IDREF #IMPLIED
>
]>
<persons>
<person pid="p1" sex=" male " qq="193968" parent="p2">
<name> Zhang Xiaoming </name>
<age>10</age>
<contact>
<phone>1234567</phone>
</contact>
<br/>
</person>
<person pid="p2">
<name> Zhang Daming </name>
<age>35</age>
<contact>
<email>[email protected]</email>
</contact>
</person>
</persons>
Four .XML Existing problems
We set the specification so that when we don't write according to the specification , Immediately remind us that there is a problem , But if there is no problem with how to write , Please follow the following steps to set .
To open the first Window ==> Preferences ==>Validation, Then check the selected . Click Apply , And then restart eclipse.
That's all for today's study .
边栏推荐
- Qcombox (rewrite) + qcompleter (auto completion, auto loading the drop-down options of qcombox, setting the background color)
- 424. The longest repeated character after replacement ●●
- 开关电源Buck电路CCM及DCM工作模式
- The PostgreSQL column reference 'ID' is ambiguous - PostgreSQL column reference'id'is ambiguous
- MySQL delete uniqueness constraint unique
- Tips for using pads router
- GFS Distributed File System
- TVS管和ESD管的技術指標和選型指南-嘉立創推薦
- Neural structured learning - Part 3: training with synthesized graphs
- C # input how many cards are there in each of the four colors.
猜你喜欢
How to rotate the synchronized / refreshed icon (EL icon refresh)
Rasa 3. X learning series -rasa 3.2.1 new release
PV静态创建和动态创建
Live tiktok shop 2022 latest gameplay card slot overseas live e-commerce new traffic
5. Logistic regression
CAS and synchronized knowledge
Spire. PDF for NET 8.7.2
20.移植Freetype字体库
Dynamic planning: robbing families and houses
教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!
随机推荐
Hcip course notes-16 VLAN, three-tier architecture, MPLS virtual private line configuration
XML配置文件(DTD详细讲解)
ts类型声明declare
98. 验证二叉搜索树 ●●
GFS distributed file system
CloudCompare&PCL 点云随机添加噪声
Switching power supply buck circuit CCM and DCM working mode
妙才周刊 - 8
激光slam学习记录
openssl-1.0.2k版本升级openssl-1.1.1p
用列錶初始化你的vector&&initializer_list簡介
Golang code checking tool
开源crm客户关系统管理系统源码,免费分享
Neural structured learning 4 antagonistic learning for image classification
带外和带内的区别
跟着CTF-wiki学pwn——ret2libc1
《牛客刷verilog》Part III Verilog企业真题
idea 连接mysql ,直接贴配置文件的url 比较方便
TVS管和ESD管的技術指標和選型指南-嘉立創推薦
Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste