DIV CSS Standard make Web learning learn the elements of the DTD

Source: Internet
Author: User
Tags empty header xml example
css| Standard | Web page

In a DTD, XML elements are declared through a DTD element declaration.

Declaring an Element

In DTDs, XML elements are declared through element declarations. Element declarations use the following syntax:

<! Element element name Category >

Or

<! Element elements name (element content) >

Empty element

Empty elements are declared by category keyword empty:

<! Element name Empty>

Example:

<! ELEMENT BR empty>

XML Example:

<br/>

Only pcdata elements.

Only pcdata elements are declared through the #pcdata in parentheses:

<! Element name (#PCDATA) >

Example:

<! ELEMENT from (#PCDATA) >

Elements with content

The element that is declared by the category keyword any can contain a combination of any resolvable data:

<! Element name Any>

Example:

<! ELEMENT Note any>

Elements with child elements (sequences)

Elements with one or more child elements are defined by the name of the child element in parentheses:

<! element name (child element name) >

Or

<! element name (child element name, child element name,.....) >

Example:

<! ELEMENT Note (to,from,heading,body) >

When child elements are declared in a comma-delimited sequence, the child elements must appear in the document in the same order. In a complete declaration, child elements must also be declared, and child elements can also have child elements. The complete declaration of the "note" element is:

<! ELEMENT Note (to,from,heading,body) ><! ELEMENT to      (#PCDATA) ><! ELEMENT from    (#PCDATA) ><! ELEMENT heading (#PCDATA) ><! ELEMENT body    (#PCDATA) >

To declare an element that appears only once

<! element name (child element name) >

Example:

<! ELEMENT Note >

The example above declares that the message child element must appear once, and must appear once in the "note" element.

Declare elements that appear at least once

<! element name (child element name +) >

Example:

<! ELEMENT Note (message+) >

The plus sign in the example above declares that the message child element must appear at least once within the "note" element.

Declare an element that appears 0 or more times

<! element name (child element name *) >

Example:

<! ELEMENT Note (message*) >

The asterisk in the example above declares that the child element message can appear 0 or more times within the "note" element.

Declare an element that appears 0 times or once

<! element name (child element name?) >

Example:

<! ELEMENT note (message?) >

The question mark in the above example declares that the child element message can appear 0 or one times within the "note" element.

Declare "Non .../..." type of content

Example:

<! ELEMENT Note (To,from,header, (message|body)) >

The above example declares that the "note" element must contain a "to" element, a "from" element, "header" element, and a "body" element that is not a "message" element.

Declaring a mixed type of content

Example:

<! ELEMENT Note (#PCDATA |to|from|header|message) *>

The above example declares that the "note" element can contain pcdata, "to", "from", "header", or "message" that appear 0 or more times.



Related Article

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.