当前位置:网站首页>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 .
边栏推荐
- Introduction to JVM
- 20220703 周赛:知道秘密的人数-动规(题解)
- Problem solving win10 quickly open ipynb file
- C file and folder operation
- orgchart. JS organization chart, presenting structural data in an elegant way
- C# 文件与文件夹操作
- 698. Divided into k equal subsets ●●
- Spire Office 7.5.4 for NET
- Use CAS instead of synchronized
- Open source CRM customer relationship system management system source code, free sharing
猜你喜欢
MySQL replace primary key delete primary key add primary key
JVM details
【LeetCode】5. Valid Palindrome·有效回文
Neural structured learning 4 antagonistic learning for image classification
What if the C disk is not enough? Let's see how I can clean up 25g of temp disk space after I haven't redone the system for 4 years?
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
el-cascader的使用以及报错解决
保研笔记一 软件工程与计算卷二(1-7章)
Xinyuan & Lichuang EDA training camp - brushless motor drive
保研笔记二 软件工程与计算卷二(13-16章)
随机推荐
Attacking technology Er - Automation
Laser slam learning record
Online yaml to CSV tool
Go language introduction detailed tutorial (I): go language in the era
ts类型声明declare
C reflection and type
如何获取localStorage中存储的所有值
用列表初始化你的vector&&initializer_list简介
Spécifications techniques et lignes directrices pour la sélection des tubes TVS et ESD - Recommandation de jialichuang
帶外和帶內的區別
Senparc.Weixin.Sample.MP源码剖析
STM32__06—单通道ADC
STM32__ 06 - single channel ADC
Qt QPushButton详解
Cwaitabletimer timer, used to create timer object access
Which side projects can be achieved? Is it difficult for we media to earn more than 10000 a month?
698. 划分为k个相等的子集 ●●
Spreadjs 15.1 CN and spreadjs 15.1 en
Rasa 3.x 学习系列-Rasa 3.2.1 新版本发布
C# 反射与Type