Example Analysis of xml constraint Technology dtd
This article mainly introduces the xml constraint technology dtd example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
1. Official DTD tutorial
# # 2.xml constraint Technology:
DTD constraints: the syntax is relatively simple and the function is relatively simple. Appear first
Schema constraints: the syntax is relatively complex and the functionality is relatively powerful. In a way similar to xml syntax, Schema constraints appear to replace DTD constraints.
Introduction to 3.DTD:
The document type definition (DTD) defines a legitimate XML document building module. It uses a series of legal elements to define the structure of the document. DTD can be declared in a row in an XML document or as an external reference.
3.1 how to import DTD:
1. Internal import:
# Import method: # instance:] > ToveJaniReminderDon't forget me this weekend (second line) defines that this document is a document of type note (root tag).
(third line) defines that the note element has four elements (tags): "to, from, heading, body"
(line 4) define the to element as "# PCDATA" type
(line 5) define the frome element as "# PCDATA" type
(line 6) define the heading element as "# PCDATA" type
(line 7) define the body element as "# PCDATA" type
External import method:
Local file:
# Import method: # note.dtd file content:
Public external import: general projects use public external import. For example, ssh's xml file basically adopts this method.
# Import method: # such as hibernate.cfg.xml:3.2DTD syntax:
1. Constraint label
Syntax:
Or category:
Empty tag: EMPTY. Indicates that the element must be an empty element. For example:
Normal string: (# PCDATA). Indicates that the content of the element must be a normal string (cannot contain child tags). For example:
Anything: ANY. Indicates that the content of an element can be any content (including child tags) for example:
Element content:
Order problem:: the number of sub-tags in order: tags: must and only occur once. Label +: the label appears at least once *: 0 or n times. Label? : 0 or 1 time. Declare "not. / both." Content of the type
two。 Constraint attributes:
Syntax:
Attribute type:
CDATA: indicates a normal string (en1 | en2 |..): indicates that it must be one of the optional values ID: indicates that the attribute value must be unique in an xml document. Value cannot start with a number
Default value:
# REQUIRED attribute value is required # IMPLIED attribute is not required # FIXED value attribute is not required, but property value is fixed
3.3 the tests are as follows. Please take a closer look at the notes:
] > ToveJaniReminderDon't forget me this weekend Thank you for reading this article carefully. I hope the article "sample Analysis of xml constraint Technology dtd" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!