当前位置:网站首页>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

边栏推荐
- 数字化转型企业成功的关键,用数据创造价值
- XML语法、约束
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
- ffmpeg 音频相关命令
- 新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
- OpenCV视频质量诊断----视频遮挡诊断
- Specification of lumiprobe reactive dye indocyanine green
- sql查询去重统计的方法总结
- 宝,运维100+服务器很头疼怎么办?用行云管家!
猜你喜欢

Dlib+Opencv库实现疲劳检测

Dlib+opencv library for fatigue detection

Lake Shore - crx-em-hf low temperature probe station

Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency

Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference

Solution and summary of Nacos startup failure

案例分享:QinQ基本组网配置

ddr4测试-2

研究了11种实时聊天软件,我发现都具备这些功能…
![Thesis reading [distinctive late semantic graph for video capturing]](/img/d4/4f84a73a9127fa87bb0a74c4655d15.png)
Thesis reading [distinctive late semantic graph for video capturing]
随机推荐
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
Nacos configuration file publishing failed, please check whether the parameters are correct solution
【pytorch记录】自动混合精度训练 torch.cuda.amp
MySQL common graphics management tools | dark horse programmers
241. Different Ways to Add Parentheses
正则表达式=Regex=regular expression
Lumiprobe free radical analysis h2dcfda instructions
物联网平台thingsboard搭建学习记录
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
EasyGBS网络不稳定情况下重复请求视频拉流问题的优化
ffmpeg 错误码
Parallelism, concurrency and life cycle of threads
Dlib+Opencv库实现疲劳检测
How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?
微信公众号开发相关流程及功能介绍
XML syntax, constraints
任务:拒绝服务DoS
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
[to.Net] C set class source code analysis
Dom4J解析XML、Xpath检索XML