Getting started with XML-sample property declaration code

Source: Internet
Author: User
A valid XML document must declare the attributes of the element. You can use the ATTLIST declaration to declare multiple attributes for an element type. A valid XML document must declare the attributes of the element. The ATTLIST declaration is used to complete the process. an ATTLIST can be an element type and a valid XML document. the attribute of the element must be declared. You can use the ATTLIST declaration to declare multiple attributes for an element type.

In the preceding example, the image element must have a src attribute. The value of this attribute is character data. ATTLIST can be used to declare multiple attributes for an element, for example:

The preceding statement states that the src, width, and height attributes are mandatory, and the alt attribute is optional. 1. attribute type

The CDATA type attribute value can contain any text string. DTD cannot specify an attribute as an integer or a date. Schema can provide a more powerful data type.

The NMTOKEN type property value is an XML name mark. The XML name mark is similar to the XML name, but the XML name mark allows all characters as the start character of the name, and the first letter of the XML name must be letters, ideographic characters, and underscores. Therefore, 10. bashrc is a legal XML name tag, but it is not a legal XML name. Each XML name is an XML name tag, but the XML name tag is not all XML names. If the attribute contains integers such as 1990,2005, you should specify its type as NMTOKEN. For example:

 

The NMTOKENS type attribute contains one or more XML name tags separated by spaces. For example:

 
  person
 

The corresponding declaration should be:

 

On the other hand, this statement cannot be used for forms such as 01/02/2005, because the forward slash is not a legal name character.

Enumeration declaration, which does not require keywords. List all values directly, separated by vertical bars in the middle. For example:

 

For the preceding declaration, the month attribute of the date element can be one of the 12 months.

The property of the ID type must contain an XML name, which is unique in the document. The ID attribute can be assigned a unique identifier for the element.

 

Because the number is not a legal XML name, the ID number cannot start with a number. the solution is to prefix it with an underscore or letter.

The IDREF type attribute points to the ID type attribute of an element in the document. Therefore, it must be an XML name. its function is to establish many-to-many relationships between elements when simple inclusion relationships cannot meet requirements. For example:

  
  
   deploy linux
   
   
  
  
  
  
   linuxsir
    
 

The project_id attribute of the project element and the card_id attribute of the person element should be of the ID type. The person_card_id attribute of the team_member element and the project_project_id attribute of the assignment element are of the IDREF type. The statement is as follows:

  
  
  
 

An attribute of the IDREFS type contains a list of XML names. The names are separated by spaces, and each name is the ID of an element in the document. This element is used when an element needs to reference multiple other elements. For example:

  
 

The corresponding documents can be written as follows:

  
  
   deploy linux
   
  
  
  
   Linuxsir
   
 

Attributes of the ENTITY type are included in the name of the non-analytic object declared by other positions of the DTD. For example, the movie element may have an object attribute that identifies the playback of mpeg or rm files during activation:

 

If the DTD declares an un-analytic entity named play, this movie element can be used to embed a video file in an XML file:

 

The attributes of the ENTITIES type include the names of non-analytic ENTITIES declared in other positions of the DTD, which are separated by spaces.

 

If the DTD declares the non-analytic entities slide1, slide2, slide3,..., you can use the slide_show element to embed slides in the XML document.

 

The NOTATION type attribute contains the name of a method declared in the document's DTD. This attribute type is rarely used. Theoretically, this attribute can be used to associate certain special elements with types. the following statement defines four methods for different Image types, each image element must select a type attribute.

  
  
  
  
 

The value of the type attribute of each image element can be gif, tiff, jpeg, or png. This attribute is slightly more advantageous than the enumeration type, because the actual MIME media type of the recording method is theoretically available. Because the slash is not a valid character in the XML name, image/png or image/jpeg cannot be specified as a allowed value in the enumeration type.

2. default attribute values
In addition to providing a data type, each ATTLIST declaration also declares the default behavior of attributes.

# IMPLIED: Optional.

# REQUIRED, which must have attributes.

# FIXED: the attribute is a constant and cannot be changed.

 

Literal is the actual default value of a referenced string.

  

If the name attribute of the specified person element is not displayed, the value is linuxsir.

The above is the details of the sample code for property declaration in the XML getting started tutorial. For more information, see other related articles in the first PHP community!

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.