DTD of 006_02xml Constraint

Source: Internet
Author: User

XML technology, you can write a document to constrain an XML writing specification, a document called a constraint.

Common constraint Techniques:

  XML DTD

Xdr

SOX

XML Schema

Quick start of DTD:

  DTD (document type definition): Documentation type definitions.

  

The syntax of a DTD document mainly involves the following definition:

Defining elements

Use the element keyword in a DTD document to declare an XML element.

Syntax: <! Element name Usage Rules >

Usage Rules:

(#PCDATA): Indicates that the body content of an element can only be normal text. (Parsed Character Data)

Empty: Used to indicate that the body of the element is null. such as <br/>

Any: Used to indicate that the body content of an element is of any type.

(child Element): Indicates the child element contained in the element

Define child elements and describe their relationships:

If the child elements are separated by commas, the XML document must be written in the order in which they are declared.

such as: <! ELEMENT FILE (Title,author,email)

If the child element uses the "|" Separate, explain any choice.

such as: <! ELEMENT FILE (title| author| EMAIL)

With +, *,? To indicate the number of occurrences of an element

If there is no +* behind the element?: Indicates that only one occurrence must occur

+: Indicates at least one occurrence, one or more times

*: Denotes dispensable, 0 times, one or more times

?: Indicates that there can or may not, and some words can only be once. 0 or one time

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

Defining properties

Use the Attlist keyword in a DTD document to declare attributes for an element.

Syntax: <! Attlist element Name Property Name 1 property value type set Description Property Name 2 property value type set description ... >

Property value type:

CDATA: Indicates that the value of the property is a normal text string

Enumerated (DTD does not have this keyword): Represents an enumeration and can only be selected from the enumeration list, such as (chicken | beef | pork | fish)

ID: Indicates that the value of the property cannot be duplicated

Setup instructions

#REQUIRED: Indicates that the property must appear

#IMPLIED: Indicates that the property is optional

#FIXED: Indicates that the value of the property is a fixed value. Syntax: #FIXED "fixed value"

Direct value: Indicates that the value of the property is the default value

Defining entities

Defining an entity is specifying a name for a piece of content so that it can refer to what it represents by using that name.

Use the Entity keyword in a DTD document to declare an entity.

Entities can be divided into: reference entities and parameter entities, with different syntax

Referencing entities

Concept: defined in a DTD, used in XML

Syntax: <! Entity entity name "Solid content" >

The reference method (note is used in XML):& entity name;

Parameter entity

Concept: defined in DTD, used in DTD

Syntax: <! Entities% entity name "Entity Content" >

Reference method (note is used in DTD):% entity name;

DTD of 006_02xml Constraint

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.