当前位置:网站首页>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 .
边栏推荐
- 424. The longest repeated character after replacement ●●
- STM32__ 06 - single channel ADC
- JVM details
- Online yaml to CSV tool
- 开源crm客户关系统管理系统源码,免费分享
- CAS and synchronized knowledge
- Brushless drive design -- on MOS drive circuit
- 【SQL】各主流数据库sql拓展语言(T-SQL 、 PL/SQL、PL/PGSQL)
- 哪些偏门项目可以做到?自媒体做到月赚一万以上很难吗?
- Do you regret becoming a programmer?
猜你喜欢

Huawei simulator ENSP - hcip - MPLS experiment

el-cascader的使用以及报错解决

MySQL replace primary key delete primary key add primary key

教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!

CIS基准测试工具kube-bench使用

How to get all the values stored in localstorage

Spire Office 7.5.4 for NET

Biased sample variance, unbiased sample variance

Qt QPushButton详解

保研笔记二 软件工程与计算卷二(13-16章)
随机推荐
CAS and synchronized knowledge
Neural structured learning - Part 2: training with natural graphs
When to use useImperativeHandle, useLayoutEffect, and useDebugValue
Opencvsharp (C openCV) shape detection and recognition (with source code)
20. Migrate freetype font library
XML配置文件(DTD详细讲解)
[EF core] mapping relationship between EF core and C data type
Fiddler Everywhere 3.2.1 Crack
Open source CRM customer relationship system management system source code, free sharing
C# 反射与Type
15 MySQL-存储过程与函数
Objective C message dispatch mechanism
用列表初始化你的vector&&initializer_list简介
Différence entre hors bande et en bande
Laser slam learning record
Attacking technology Er - Automation
俄外交部:日韩参加北约峰会影响亚洲安全稳定
如何让同步/刷新的图标(el-icon-refresh)旋转起来
Problem solving win10 quickly open ipynb file
How to insert data into MySQL database- How can I insert data into a MySQL database?