DTD Simple to use

Source: Internet
Author: User

Dtd:document Type Definition

DTD is a simple XML constrained schema language

DTD documents must be encoded in Utf-8 or Unicode

Annotations in the same way as HTML, XML documents

References to DTD documents: There are two ways to follow an XML declaration statement (externally introduced and embedded internally)

<?xml standalone= "No"?>
<! DOCTYPE ... >

Externally introduced DTD mode:

There are two ways of referencing: the first is to reference the local DTD file, and the second is the public DTD file (Doctype-name is typically named with the root element)

1 <! DOCTYPE doctype-name SYSTEM "Dtd-url" > 2 <! DOCTYPE Doctype-name  Public "Dtd-name" "Dtd-url">

Internally embedded DTD mode:

1 <! DOCTYPE doctype-name [2   3]>

A simple DTD document is as follows:

<! ELEMENT Bookshelf (book+)>2     <!  ELEMENT Book (name,author,price)><!  ELEMENT name (#PCDATA)><!  ELEMENT author (#PCDATA)><!  ELEMENT Price (#PCDATA)>              

DTD element definition:<! Element name usage rules >

The following rules apply:

Empty: Define NULL elements

Any: In any form

(#PCDATA): normal text

(<ELE1> <ELE2> <ELE3> ...) : unordered element Group

(<ELE1>,<ELE2>,<ELE3> ...) : Ordered element group (requires child elements to be <ELE1>, <ELE2>, <ele3> The order in which they appear)

(<ELE1>|<ELE2>|<ELE3> ...) : Only one element

The following three kinds of elements can be added after the wildcard character (+: appear one or more times;?: appears 0 or more times; *:0 or multiple times; there is nothing to indicate and only once)

such as:<! ELEMENT MYFILE (title*, Author?,email) *| COMMENT)>

The DTD attribute definition:

<! attlist element name

Att1 Property Type setting description

...

>

The property types are as follows:

CDATA: String

Enumerated

Id

...

The setup instructions are as follows:

#REQUIRED: Must be set

#IMPLIED: Optional

#FIXED ' fixed ': fixed value

"Default": Setting defaults

such as:<! Attlist meat Kind (chicken|beaf|fish| ...) "Fish">

DTD entity definition:<! Entity name "Content">

DTD simple use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.