WML program structure based on Wireless Markup Language (WML)

Source: Internet
Author: User
Tags define end range require version domain client access
Program previous SectionWe degrade a simple WML program, and readers with HTML programming can see that the WML program has much in common with the HTML program in its structural form. Here we will analyze the structure and composition of the WML program based on an example.

   1. WML Elements and labels

Before analyzing an instance, it is necessary to briefly explain the elements and tags of WML. Like HTML, the main syntax for WML is also elements and tags. Elements are part of a document that conforms to a DTD (document-like definition), such as title (document title), IMG (image), table (table), and so on, and element names are case-insensitive. WML uses labels to specify the attributes of an element and its location in the document. tags are enclosed in the less-than sign (") and greater-than (") ", which means" label ". Labels are divided into separate labels and pairs of labels that appear. Most labels appear in pairs, consisting of a first and a trailing label. The first and end labels are also called starting and ending labels, respectively. The first label is formatted as "element name >" and the tail label is in the form "</element name". A pair of labels is used to specify the range of elements, compared to the lt;b> and </b> tags are used to define the range of bold words, that is, the parts that are wrapped between <b> and </b> are shown in bold text. The individual label is formatted as "element name/>", and his role is to insert the element at the appropriate position. A 〈br/〉 label indicates that a newline character is inserted where the label is located.

   2. Analysis of the structure form and composition of WML program

After understanding the above knowledge, we are analyzing an instance program below. The procedure is as follows:

<?xml version= "1.0"? > >
! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapfourm.org/DTD/wml_1.1.xml"

<wml>

<card id= "Card1" ontimer= "#card2" title= "Tookit Demo"
<timer value= "50"/>
<p aligh= "Center"
</br> </br> </br>
<big>
!--Write your Card implementation here.-->
Welcome to ....
</big>

</p>
</card>

<card id-"Card2" ontimer= "#card 3" title= "Toolkit Demo" >
<timer value= "50"/>
<p align= "Center"
<br/> <br/>
<b>
The Nokia <br/>
</b>
Wireless Application Protocol
</u>
...
</p>
</card>

<card id= "Card3" title= "Toolkit Demo" >
<p align= "Center"
<br/> <br/> <br/>
<big>
<i>
Toolkit
</i>
</big>
</p>
</card>
</xml>
After the program is running, it will display 3 screen information in the WAP phone screen in turn. First show "Welcome to ..." and then display "The Nokia Wireless application Protocol ..." and finally "tookit!". Display each screen has a title "Tookit Demo", the adjacent two screens between the delay of 50, the unit size of 1/10 seconds, the delay of 50 or 5 seconds.

From the above examples we can understand the structure and composition of the WML program:

1) syntax. WML is very similar to HTML. is still a markup language, and continues the syntax rules of XML, the specific syntax we will encounter later in the learning process.

2) file declaration. All WML programs must declare the XML file type at the beginning of the file, including the version of XML, the document type of WML, the specification used, and so on. The form of the Declaration is as follows:

<?xml version= "1.0" >
! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
3) label. The use of tags (tag) in WML languages is exactly the same as in the form of markup languages such as HTML and XML.

4) element. The elements of WML (element) are used to describe the tag information of the card Group (Deck), which is the structure information. An element usually consists of a first label, content, other elements, and a tail tag, which has one of two structures:

First label > content </Tail label

Or

Tags/>

Elements can also be included in an element, which is also composed of a first label, corresponding content, other elements, and a tail tag. Elements that do not contain content become empty elements. It is a separate label. Alternatively, a separate label is an element.

5) attribute. WML, like XML, has a label that can contain many properties. property is used to provide the necessary additional information to the label, and the property content is usually used within the start tag. However, the property content is not displayed by the browser, and it provides the necessary information as a parameter for the label.

When you indicate a property value, you need to enclose the value in quotation marks, either single or double quotes, which are usually nested in pairs. The property name must be lowercase. For example: <card id= "card 1" ontimer= "#card2" title= "Toolkit Demo" >

Also, the properties of single quotes can contain double quotation marks. Entity characters can also be property values. Entity characters are special characters such as &, ",", ', ', and display the class characters in a WML program that require special handling, followed by a specific method.

6) Notes. Annotations can also be added to the WML program. Annotation content is used to facilitate developers to read the source code smoothly, it will not be displayed by the browser. The annotation content is tagged with an exclamation point (! ) and used in the form of the--> of the!--annotation content. For example:!--Write your card implementation here.-->. It is necessary to note that annotations are not nested in XML programs.

7) Document structure. WML documents are composed of "card" and "card Group (Deck)", and a Deck is a collection of one or more cards. When a client makes a request, WML sends the deck from the network to the client browser, which allows the user to browse all the card contained within the deck without having to download each card separately from the Web, the first card in the program is the default card that is visible.

Note: Deck is the meaning of a deck of cards, this is a stack of cards, so we call it the "card group" here. In addition, card refers to the WAP phone screen size of the page, although sometimes a card may require multiple screens to display, but we can also translate it to "page", but this is easy to mix with the pages in HTML. So here we call it a card.

   3, the basic structure of the WML program

We have simply analyzed the structure and composition of WML, so you can have a general understanding of the WML program. Below we give the basic structure of the WML program.

<?xml version= "1.0"? > >
! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1xml"
<wml>
<access/>
<meta..../>
<card>
Some contents ...
</card>
<wml>
The basic structure can be divided into the following key sections:

1) statement. The WML program has many deck components, and for each deck, the declaration of the XML and the document type DOCTYPE must be declared at the beginning of the document.

The XML declaration is always on the first line of the file, and note that it is best not to have spaces or rows in front:

<?xml version= "1.0"? > >
2 followed by the DOCTYPE statement, note that the statement is the case of the letter do not make mistakes:

! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1xml"
3) <xml> label. This label is used to include and define a deck for WML. It has an optional Xml:lang attribute to develop the language of the document, such as <wml xml:lang= "en", which means that the document language is Chinese.

4)
5) <access/> label. Its general form is the <access domain= "domain" path= "/Path"/>, which is primarily used to make access control information for the current deck, with two optional properties. Where domain is used to make domains, the default value is the current domain, and path is used to make paths, the default value is "/", that is, the directory. Because the <access> used alone, so to use the "/" end, we will also systematically explain the various types of WML tags, here, even if you do not understand it does not matter, mainly some perceptual understanding on it.

6) <meta ... > tags. Its general form is the <meta property content= "value" scheme "format" forua= "True|false"/>, which is used to provide meta information about the current deck, including how memory is processed, how and how data is transmitted, and how it is handled. The details of the label are given later in this section.

7) <card> label. A deck can contain more than one card, and the contents of each card may be displayed more than a single screen. Each CARD,WML is included and defined using <card> and </card>. The <card> can also contain multiple optional properties, such as <card id= "name" title= "label" newcontext= "false" ordered= "true" onenterforwand= "url" pmemterbackward= "url" ontimer= "url". As for the specific meaning and function of these attributes, we will introduce them later.

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.