当前位置:网站首页>XML DTD record
XML DTD record
2022-06-23 06:53:00 【Small code 2016】
Introduction mode
Inside DTD
take DTD And XML Data definitions in the same document
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Inside DTD -->
<!DOCTYPE books[
<!ELEMENT books (book)*>
<!ELEMENT book (name,autor,price,desc)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT autor (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
]>
<!-- xml file -->
<books>
<book>
<name>java</name>
<autor>laolang</autor>
<price>500</price>
<desc>java Books </desc>
</book>
<book>
<name>php</name>
<autor>php</autor>
<price>400</price>
<desc>php Books </desc>
</book>
</books>
external DTD
dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT books (book)*>
<!ELEMENT book (name,autor,price,desc)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT autor (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "one.dtd">
<books>
<book>
<name>java</name>
<autor>laolang</autor>
<price>500</price>
<desc>java Books </desc>
</book>
<book>
<name>php</name>
<autor>php</autor>
<price>400</price>
<desc>php Books </desc>
</book>
</books>
public DTD
DTD Document structure
The first 1 Line is DTD Declaration part , And XML identical
0 To multiple comments , And XML identical
0 To more than one <!ELEMENT…> Definition , Every <!ELEMENT…> Define a XML Elements
0 To more than one <!ATTLIST…> Definition , Every <!ATTLIST…> by XML Element defines an attribute
0 To more than one <!ENTITY…>, Every <!ENTITY…> Define an entity
0 To multiple <!NOTATION…> Definition , Every <!NOTATION…> Define a symbol
this 4 Elements do not need to be nested within each other
ELEMENT
<!ELEMENT Element name Element type description >The description of element types mainly includes the following 5 Kind of :
- Any type
This element can be either a string , It can also contain other child elements , It can also be an empty element - A string value
This element can only be a string , Cannot contain other child elements , Nor can it be an empty element - Empty elements
This element can be an empty element , Neither can it contain child elements , Nor can it contain string values - Contains child elements
It is necessary to define the order between child elements and the number of times that child elements appear in detail - Mixed type
Appoint XML The value of an element can only be of certain types , Mixed types are stronger than constraints of any type
Any type
grammar : <!ELEMENT Element name ANY>
example :
DTD
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT books ANY>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "one.dtd">
<books>
books
</books>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "one.dtd">
<books/>
Empty elements
grammar : <!ELEMENT Element name EMPTY>
example :
DTD
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT books EMPTY>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "one.dtd">
<books/>
character string
grammar : <!ELEMENT books (#PCDATA)>
example :
DTD
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT books (#PCDATA)>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books SYSTEM "one.dtd">
<books>
books
</books>
Mixed content
grammar :<!ELEMENT Parent element name (#PCDATA | Subelement 1 | Subelement 2 | Subelement 3 ...)*>
Specifies that the contents of the parent element can be either ordinary strings , It can also be the child element specified by each child element name . It's worth pointing out , The child elements here 1、 Subelement 2 The vertical line between and subprime three does not indicate mutual exclusion , It just means that these child elements can repeat in disorder , The number of occurrences is unlimited .
dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT games (#PCDATA | game)*>
<!ELEMENT game (#PCDATA | name | type)*>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE games SYSTEM "one.dtd">
<games>
Games and programming are similar , It is a kind of interest
<game>
<type> Action fighting </type>
<name> Waiting soul </name>
Suitable for releasing tension 、 A dull feeling
</game>
<game>
Relax 、 A good game to soothe your mood
<name> Thunder and lightning </name>
<type> Flying shooting </type>
</game>
<game>
<name> Thunder and lightning </name>
</game>
<game>
<name> Thunder and lightning </name>
<name> Waiting soul </name>
</game>
</games>
Subelement
Ordered child elements
If you use an English comma as a separator between child elements , The defined order must be observed between the child elements
dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT games (game)*>
<!ELEMENT game (name,type)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE games SYSTEM "one.dtd">
<games>
<game>
<name> Waiting soul </name>
<type> Action fighting </type>
</game>
<game>
<name> Thunder and lightning </name>
<type> Flying shooting </type>
</game>
</games>
Mutually exclusive child elements
Mutually exclusive child elements indicate that only one of them can appear between a series of child elements . Use vertical lines to separate
dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT games (game)*>
<!ELEMENT game (name | type)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE games SYSTEM "one.dtd">
<games>
<game>
<name> Waiting soul </name>
</game>
<game>
<type> Flying shooting </type>
</game>
</games>
Sub element frequency
- +: appear 1 Times or times
- *: appear 0 Times or times
- ?: appear 0 Once or once
- No frequency specified : Can only occur and must occur once
Combine child elements
Use parentheses to enclose multiple child elements to form an element group , The child elements in the element group can be separated by commas , To indicate that the elements in the element group are in order , You can also use digital display to express mutual exclusion . You can use tags that represent frequencies to follow groups of elements , Used to indicate the frequency of occurrence of the element .
Unordered child elements
dtd There is no specific definition of unordered child elements , However, it can be realized with the help of element groups
<!ELEMENT games (game)*>
<!ELEMENT game(name|autor|price|type)+>
<ELEMENT name (#PCDATA)>
<ELEMENT autor (#PCDATA)>
<ELEMENT price (#PCDATA)>
<ELEMENT type (#PCDATA)>
Defining attributes
<!ATTLIST The element to which the attribute belongs Property name Attribute types [ Element constraints on attributes ] [ The default value is ]>
Not specified in “ Element constraints on attributes ” when , You must specify a default value for this property
When “ Element constraints on attributes ” yes #REQUIRED when , Default value... Cannot be specified
When “ Element constraints on attributes ” yes #IMPLIED when , Default value... Cannot be specified
When “ Element constraints on attributes ” yes #FIXED when , You must specify a default value
#REQUIRED : must
#IMPLIED : not essential
#FIXED : Fixed attribute
Attribute types 
Entity
Symbol
done
边栏推荐
- 从 WAN 到 SD-WAN 边缘设备的网络架构
- cetos7 记录
- C language removes line breaks (or other characters) at the end of strings
- QT method of compiling projects using multithreading
- Easy EDA #学习笔记09# | ESP32-WROOM-32E模组ESP32-DevKitC-V4开发板 一键下载电路
- 如何查看本机IP
- Haas 506 2.0 Tutoriel de développement - bibliothèque de composants avancés - modem. SMS (ne prend en charge que les versions supérieures à 2,2)
- QT设计师无法修改窗口大小,无法通过鼠标拖动窗口改变大小的解决方案
- Sklearn classification in sklearn_ Report & accuracy / recall /f1 value
- 中台库存中的实仓与虚仓的业务逻辑设计
猜你喜欢

Copy and paste of idea without escape

快速认识 WebAssembly

swagger3整合oauth2 认证token

Data indicators and data analysis models that designers need to understand

Media industry under the epidemic situation, small program ecology driven digital transformation exploration

Sword finger offer 42 Maximum sum of successive subarrays

Explain csma/cd, token bus and token ring clearly

haas506 2.0开发教程-高级组件库-modem.sms(仅支持2.2以上版本)

994. 腐烂的橘子-非递归法

Qt 中 QVariant 使用总结
随机推荐
网页制作存在的一些难点
Programmers' real ideas | daily anecdotes
WPF Command指令和INotifyPropertyChanged
中台库存中的实仓与虚仓的业务逻辑设计
core. What is JS ---kalrry
Copy and paste of idea without escape
20220621 Dual Quaternion
haas506 2.0开发教程-高级组件库-modem.net(仅支持2.2以上版本)
Test of ers function under the supplier consignment purchase mode of SAP mm
Sklearn classification in sklearn_ Report & accuracy / recall /f1 value
mysql 优化
Cloud box is deeply convinced to create a smart dual-mode teaching resource sharing platform for Nanjing No. 1 middle school
关于监督
Easy EDA #学习笔记09# | ESP32-WROOM-32E模组ESP32-DevKitC-V4开发板 一键下载电路
Problem: when the attribute in the data object (defined data) in the access component is also the attribute in the object object, an error is reported
Measurement principle and thickness measurement mode of spectral confocal
Get to know webassembly quickly
js中if逻辑过多,常见优化
快速认识 WebAssembly
聚焦智慧城市,华为携手中科星图共同开拓数字化新蓝海