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