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

边栏推荐
猜你喜欢

【To .NET】C#集合类源码解析

Once the SQL is optimized, the database query speed is increased by 60 times

Supervarimag superconducting magnet system SVM series

【森城市】GIS数据漫谈(一)

Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase

如何正确使用Vertx操作Redis(3.9.4带源码分析)

ubuntu14安装MySQL并配置root账户本地与远程访问
![[pytorch record] automatic hybrid accuracy training torch cuda. amp](/img/a5/cf1eb2801380cf2887dfd532d3eb1e.jpg)
[pytorch record] automatic hybrid accuracy training torch cuda. amp
![Reading the paper [learning to discretely compose reasoning module networks for video captioning]](/img/a2/acdaebeb67ec4bcb01c8ff4bbd1d1e.png)
Reading the paper [learning to discretely compose reasoning module networks for video captioning]
![[to.Net] C set class source code analysis](/img/59/4c7b910bc6505e5f81015ce80812fc.png)
[to.Net] C set class source code analysis
随机推荐
Shell高级进阶
论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】
IPv4地址、子网掩码、网关
Helium transmission line of lake shore cryostat
Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
brpc理解
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
智慧防疫系统为建筑工地复工复产提供安全保障
Solidity - contract structure - error - ^0.8.4 NEW
[go ~ 0 to 1] day 5 July 1 type alias, custom type, interface, package and initialization function
记一次 .NET 差旅管理后台 CPU 爆高分析
Dom4j parsing XML, XPath retrieving XML
axure不显示元件库
Werewolf killing strategy: do you think I'm easy to cheat? Who do we believe!
【英语语法】Unit1 冠词、名词、代词和数词
[6.24-7.1] review of wonderful technical blog posts in the writing community
Specification of lumiprobe reactive dye indocyanine green
下载(导出)pdf模板文件(比如:审批单),报错:Invalid nested tag *** found, expected closing tag ***