当前位置:网站首页>DTD modeling
DTD modeling
2022-07-01 19:31:00 【Timely】
Catalog
3、 ... and 、 The standard XML Format
stay XML Join in DTD Statement
The classification of elements
The number of times an element appears
5、 ... and 、 Attribute definitions
If xml What to do if the document reports an error ?
One 、 What is? XML?
XML,Extensible Markup Language, Extensible markup language . The suffix of the file is :.xml. It's like HTML Is used to display data ,XML Its function is to transmit and store data .
Two 、XML The role of ?
In order to facilitate different applications 、 Data sharing and communication between different platforms .
The functions of the specific points are :
(1) It can be used as a simple database , Store and retrieve data ;
(2) Transfer files in the agreed format ;
(3) Make software configuration files .【 The configuration file : Save the file of software settings 】
3、 ... and 、 The standard XML Format
- Yes and There is only one root element
- XML Label case Distinguish correctly
- Use... Correctly End tag
- correct Nested tag
- Used Legal tag name
- Definition Valid attributes
Four 、 Element definition
stay XML Join in DTD Statement
<!DOCTYPE root[]>
The classification of elements
<!ELEMENT element-name EMPTY>// Empty elements
<!ELEMENT element-name (#PCDATA)>// Text elements
<!ELEMENT element-name (e1,e2)>// Mixed elements
The limitation of elements
Symbol of element restriction
- And :(,)
- Not :(|)
The number of times an element appears
0 or 1 Time : ?
0~N Time : *
1~N Time : +
Example :
establish xml constraint , First, we have to analyze xml structure .
1、 Root tag persons There are sub tags
2、persons There are sub tags Mix labels ( There are sub tags )
3、person There are sub tags :name、age、contact、br、 Mix labels ( There are sub tags )
4、name,age No sub tags Mix labels ( There are sub tags )
5、contact There are sub tags Mix labels ( There are sub tags )
6、phone No sub tags , There are content , Text label7、email No sub tags , There are content , Text label
8、br There are neither sub tags nor text content Empty label
The code is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)>
<!ELEMENT person (name,age,contact,br?)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT contact (phone|email)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT br EMPTY>
]>
<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>
5、 ... and 、 Attribute definitions
grammar
<!ATTLIST element-name att_name type desc>
Attribute types type
ID
( male | Woman )
CDATA( Text )
IDREF( quote )
reference
Property description
#REQUIRED: Required
#IMPLIED: Not required
‘ The default value is ’
Be careful : Only type by ( male | Woman ) Type ,desc Only by default
Example
Attribute constraints
pid The attribute type is ID Required
sex The attribute type is the choice of men and women Default values can be set
qq The attribute type is text Not required
parent ( Quote a id) The attribute type is text Not required
The code is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persons[
<!ELEMENT persons (person+)>
<!ELEMENT person (name,age,contact,br*)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT contact (phone|email)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT br EMPTY>
<!ATTLIST person
pid ID #REQUIRED
sex ( male | Woman ) ' male '
qq CDATA #IMPLIED
parent IDREF #IMPLIED
>
]>
<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>
When we don't fill in according to the constraint It will cause an error Here's the picture
Be careful : There should be a space between the element name and the attribute name !!!
If xml What to do if the document reports an error ?
Window ==> Preferences ==>Validation Then check ( The default is select all ), Finally, the application closes . Be careful : Restart after setting eclipse
边栏推荐
- Dom4J解析XML、Xpath检索XML
- 数字化转型企业成功的关键,用数据创造价值
- Enabling "new Chinese enterprises", SAP process automation landing in China
- Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
- 论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
- 直播HLS协议
- English语法_形容词/副词3级 -注意事项
- ffmpeg 音频相关命令
- GB28181之SIP协议
- Case sharing: basic networking configuration of QinQ
猜你喜欢
Helium transmission line of lake shore cryostat
Introduction to relevant processes and functions of wechat official account development
奔赴山海之前,毕业季一定要做的那些事情
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
微信公众号开发相关流程及功能介绍
测试自学人必看:软件测试如何找测试项目?
Solidity - contract structure - error - ^0.8.4 NEW
Solution and summary of Nacos startup failure
Methods of finding various limits
Reading the paper [learning to discretely compose reasoning module networks for video captioning]
随机推荐
Go Language Advanced
Learning notes [Gumbel softmax]
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
ffmpeg常用命令(二)
Dlib+Opencv库实现疲劳检测
Summary of SQL query de duplication statistics methods
Specification of lumiprobe reactive dye indocyanine green
GetMessage底层机制分析
XML syntax, constraints
[pytorch record] automatic hybrid accuracy training torch cuda. amp
241. Different Ways to Add Parentheses
Learn MySQL from scratch - database and data table operations
学习笔记【gumbel softmax】
Lake shore optimag superconducting magnet system om series
智慧防疫系统为建筑工地复工复产提供安全保障
Helium transmission line of lake shore cryostat
Learning notes - steps of JDBC connection database operation
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
微信公众号开发相关流程及功能介绍
Thesis reading [distinctive late semantic graph for video capturing]