SoFunction
Updated on 2025-04-07

Simple examples of WML and editing and testing methods page 1/2

After completing the establishment of the WAP server and the installation of the WAP browser, we can use the WML language to write WAP web pages or applications and debug them through the WAP server and browser. Starting from this chapter, we will systematically learn WML language. This chapter mainly explains the basic knowledge of WML language, and the next chapter comprehensively explains the grammar, tags and rules of WML.
2.1 Simple examples of WML and editing and testing methods
The infinite markup language WML (Wireless Markup Language) is a language based on the extended markup language XML (Extension Markup Language), which is a subset of XML. It can display various text, images and other data. It was proposed by WAP Forum () and designed specifically for wireless device users to provide interactive interfaces. The current version is version 1.1. These wireless devices include mobile phones, pagers and personal digital assistant PDAs (Personal Digital Assistants).
2.1.1 WML and WAP devices
In order to better understand and use the WML language, developers should have a rough understanding of the characteristics and characteristics of the devices used by WML and devices that support WML.
Generally speaking, wireless devices used by WML usually have the following characteristics:
It is smaller than a normal personal computer;
The device has limited memory and its CPU performance is also limited;
The communication bandwidth is narrow and the delay is longer.
Taking mobile phones and PDAs as examples, devices that support WML mainly have the following characteristics:
There is a display screen that can display 2. The characters of each; 2. The characters of the evil address are supported; 2. The characters of the evil address are supported;
Support operators to use arrows or numeric buttons to make selections;
Printable codes that support ASCII;
There are usually two programmable function keys, namely the Accpet key and the Options key, which are usually arranged below the screen close to the keyboard;
There is usually a Prev navigation key.
The purpose of introducing the WAP device used in WML is to hope that readers can understand the characteristics of the WML language through the characteristics and characteristics of the WAP device, and then have a rough understanding of the problems that WML programming needs to solve.
2.1.2 WML program using text editor
When writing WAP web pages or applications in WML, you need to use an editor to edit them. Like HTML programming, programs written in WML are also plain file text and can be written using any text editor, such as "NotePad" in Windows system. You can also use software such as Nokia WAP Toolkie (the specific usage of this will be mentioned in the future learning process). Let’s introduce the first method first, and then the second one.
If you want to use Notepad to write a WML program, you can click the "Start" button in the Windows system, and then point the cursor to "Programs", "Accessories", and then start the "NotePad" program from the menu that appears. Its edit window will then appear on the screen, from which you can enter and write a WML program.
As an example, we can enter the following simple program.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//wapforun//DTD WML 1.1//EN" "/DTD/wml_1.">
<xml>
<card  title="Title">
<P>
<!--Write your card implementation here.-->
Hello World!!
</P>
</card>
</xml> 
Save it as a file after typing. Note that the file extension should be xml instead of txt when saving.
2.2 WML program structure
In the previous section we degrade a simple WML program. Readers with HTML programming can see that WML programs have many similarities in structure and form with HTML programs. Let’s analyze the structure and composition of WML programs based on an example.
2.2.1 WML elements and tags
Before analyzing the instance, it is necessary to briefly explain the elements and tags of WML. Similar to HTML, the main syntax of WML is also elements and tags. Elements are documents that conform to DTD (similar definitions for documents), such as title (document title), IMG (image), table (table), etc. The element names are case-insensitive. WML uses tags to specify the attributes of an element and its position in the document. The tag is enclosed with a less than sign (<) and a greater than sign (>), that is, it adopts the form of "<label name>". There are two types of tags that appear individually and pairwise tags. Most tags appear in pairs, consisting of the first tag and the tail tag. The first label and the tail label are also called the start label and the end label respectively. The format of the first label is "<element name>", and the format of the tail label is "</element name>". Paired labels are used to specify the range contained in the element, and the labels are used to define the range of bold characters, that is, the part wrapped between <b> and</b> is displayed in bold characters. The format of the individual tag is "<element name/>", and its function is to insert elements at the corresponding position. For example, the <br/> tag indicates that a newline is inserted at the location of the tag.
2.2.2 Example analysis of the structure and composition of WML program
After understanding the above knowledge, we are analyzing an example program below. The procedure is as follows:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<card  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 title="Toolkit Demo">
<p align="center">
<br/><br/><br/>
<big>
<i>
Toolkit
</i>
</big>
</p>
</card>
</xml> 
After the program is run, three screens of information will be displayed on the WAP mobile phone screen. First display "Welcome to ...", then display "The Nokia Wireless Application Protocol...", and finally display "Tookit!". When displayed, each screen has the title "Tookit Demo". The delay between two adjacent screens is 50, and its unit size is 1/10 second, and the delay is 50, that is, 5 seconds.
Through the above examples, we can understand the structure and composition of WML programs:
1) Syntax. WML is very similar to HTML. It is still a markup language and continues the grammar rules of XML. We will encounter specific grammars in the future in the learning process.
2) Document statement. All WML programs must declare XML file types at the beginning of the file, including the XML version, WML document types, specifications used, etc. The declaration form is as follows:
<?xml version="1.0">
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1."> 
3) Tags. Tags (Tags) are required in WML languages, and their usage forms are exactly the same as those in markup languages ​​such as HTML and XML.
4) Elements. The element of WML is used to describe the tag information of the card group (Deck), that is, structure information. An element usually consists of a first label, content, other elements and a tail label, and has one of the following two structures:
<First Tag>Content</Term Tag>
or
<Tags/
The content contained in the element can also include elements, which also consist of the first label, corresponding content, other elements and tail labels. Elements that do not contain content become empty elements. It is a separate tag. In other words, individual labels are also an element.
5) Attributes. Like XML, WML can contain many attributes. Attributes are used to provide the tag with necessary additional information, and the attribute content is usually used within the starting tag. However, the attribute content will not be displayed by the browser, and it serves as a parameter to provide the necessary information for the tag.
When specifying the value of an attribute, the value needs to be extended in quotes, which can be single or double quotes, and quotes are usually used in pairs. The attribute name must be lowercase. For example: <card  ontimer="#card2" title="Toolkit Demo">
Moreover, the single quote attribute can also contain double quote attributes. Entity characters can also be used as attribute values. Entity characters refer to special characters such as &, <,>, ', ". In WML programs, they need to be processed in special processing. We will introduce specific methods later.
6) Comments. Comments can also be added to WML programs. Comments are used to facilitate developers to read the source code smoothly, and they will not be displayed by the browser. Comment content is introduced in the tag with exclamation mark (!) and used in the form of <!--Comment content-->. For example: <!-- Write your card implementation here.-->. It should be noted that nesting of comments is not supported in XML programs.
7) Document structure. A WML document is composed of "cards" and "Decks", a Deck is a collection of one or more cards. After the client makes a request, WML sends the Deck from the network to the client browser. This is where the user can browse all the cards contained in the Deck without having to download each card separately from the network. The first card in the program is the card that is visible by default.
Note: Deck means a deck of cards, here it refers to a stack of cards, so we call it "card set" here. In addition, Card refers to a web page with the size of a WAP mobile phone. Although sometimes a Card may require multiple screens to be displayed, we can also translate it into "page", but this is easy to mix with pages in HTML. So we call it a card here.
12Next pageRead the full text