XML DTD (document type definition)

Source: Internet
Author: User
Tags cdata

A document type definition (DTD) defines a legitimate XML document building block. It uses a series of legitimate elements to define the structure of the document.

DTDs can be declared in an XML document in rows or as an external reference.

Declaring elements

In a DTD, an XML element is declared through an element declaration. The element declaration uses the following syntax:

<! Element name category > [category can Be: EMPTY, (#PCDATA), any]

Or

<! Element elements name (element content) >

An XML document instance with a DTD

<?xml version= "1.0"? ><! DOCTYPE note[  <! ELEMENT Note (to,from,heading,body) >  <! ELEMENT to      (#PCDATA) >  <! ELEMENT from    (#PCDATA) >  <! ELEMENT heading (#PCDATA) >  <! ELEMENT body    (#PCDATA) >]><note>  <to>George</to>  <from>john</from >  

! DOCTYPE Note (second line) defines this document as a type of note.

! Element Note (line three) defines a note element with four elements: "To, from, heading, body"

! element to (line fourth) defines the to element as "#PCDATA" type

! Element from (line fifth) defines the from element as the "#PCDATA" type

! Element heading (line sixth) defines the heading element as the "#PCDATA" type

! Element body (line seventh) defines the BODY element as the "#PCDATA" type

PCDATA means the parsed character data (Parsedcharacter), PCDATA is the text that will be parsed by the parser. The text will be examined by the parser entity and tagged

CDATA means character data (Characterdata). CDATA is text that will not be parsed by the parser

<! ELEMENT Note (#PCDATA |to|from|header|message) *[can be suffixed with:?, *, +]>

The above example declares that the "note" element can contain 0 or more occurrences of PCDATA, "to", "from", "header", or "message".

declaring properties

The property declaration uses the following syntax:

<! Attlist element Name Property Name property type default Value >

The following are the options for the property type:

Type description

CDATA value is character data (character)

(en1|en2|.) This value is one of the values in the enumeration list

ID value is a unique ID

IDREF value is the ID of another element

IDREFS value is a list of other IDs

NmToken value is a valid XML name

Nmtokens value is a list of valid XML names

Entity value is a solid

The entities value is a list of entities

NOTATION This value is the name of the symbol

XML: Value is a pre-defined XML value

The default value parameter can use the following values:

Value explanation

Default value of the Value property

#REQUIRED property value is required

#IMPLIED properties are not required

The value of the #FIXED Value property is fixed

Declaring entities

Grammar:

<! Entity entity name "Value of Entities" >

XML DTD (document type definition)

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.