Professional Documents
Culture Documents
WML (Wireless Markup Language)
WML (Wireless Markup Language)
WML (Wireless Markup Language)
The first two lines are known as Prolog. Every WML document starts with the prolog. The first line is the XML declaration
and the second line is the DOCTYPE declaration. The prolog components are not WML elements and they should not be
closed, i.e. you should not give them an end tag or finish them with /
Output
XML Declaration and Character Encoding
<wml>
<card>
<do type="accept">
<go href="#viewvalues">
<setvar name="var1" value="value 1"/>
<setvar name="var2" value="value 2"/>
</go>
</do>
<p>
Press OK to view variable values.
</p>
</card>
<card id="viewvalues">
<p>
$var1<br/>
$var2
</p>
</card>
</wml>
Result:
Example: A WML deck with two cards - one for user input and one for
displaying the result
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Tutorial">
<do type="accept" label="Answer">
<go href="#card2"/>
</do>
<p>
<select name="name">
<option value="HTML">HTML Tutorial</option>
<option value="XML">XML Tutorial</option>
<option value="WAP">WAP Tutorial</option>
</select>
</p>
</card>
<card id="card2" title="Answer">
<p>
You selected: $(name)
</p>
</card>
</wml>
Result :
Result :
Example explanation:
Example explanation:
The <do> element
<do> ... </do>
The first card has a <do> element that defines an event to be triggered.
The type="accept" attribute of the <do> element causes the label="Answer" to be
displayed in the lower left corner of the display.
The Event
The <go> element triggers when the user clicks the <do> label.
The href="#card2" attribute of the <go> element causes card2 to be displayed on the
screen.
The Variable
Card2 displays the $(name) variable from card1, because variables are valid across
cards.
Tasks
• an element that specifies an action to be performed by the browser,
rather than something to be displayed
• WML provides following four elements to handle four WML tasks
called go task, prev task, refresh task and noop task.
The <go> Task
• represents the action of going to a new card.
Attributes:
1. Href
2. Method
3. Sendreferer
4. Accept-charset
5. Class
6. id
The <go> task
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card title="GO Element">
<p>
<anchor>
Chapter 2 : <go href="chapter2.wml"/>
</anchor>
</p>
</card>
</wml>
The <prev> Task:
• Represents the action of returning to the previously visited card on
the history stack
• If no previous URL exists, specifying has no effect
• Most commonly used in a connection with <do> element
Attributes:
1. Class
2. id
The <prev> Task:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card title="Prev Element">
<p>
<anchor>
Previous Page :<prev/>
</anchor>
</p>
</card>
</wml>
The <refresh> task
• Its effect is simply to perform the variable assignments specified by its
<setvar> elements, then redisplay the current card with the new
values. The <go> and <prev> tasks perform the same action just
before displaying the new card.
• most often used to perform some sort of "reset" action on the card.
Attributes:
1. Class
2. id
The <refresh> task
<wml>
<card title="Referesh Element">
<p>
<anchor>
Refresh this page:
<go href="test.wml"/>
<refresh>
<setvar name="x" value="100"/>
</refresh>
</anchor>
</p>
</card>
</wml>
The <noop> task
• The purpose of the <noop> task is to do nothing (no operation).
• The only real use for this task is in connection with templates
Attributes:
1. Class
2. Id
The <noop> task
<wml>
<card title="Noop Element">
<p>
<do type="prev" label="Back">
<noop/>
</do>
</p>
</card>
</wml>
Events
• An event in WML is simply something that can happen to some
element from time to time.
• When something happens in a computer system, the system
itself has to
(1) detect that something has happened and
(2) know what to do about it.
Events
WML supports following four event types:
1. Onenterforward
2. Onenterbackward
3. Onpick
4. ontimer
WML <onevent> element
• The <onevent>...</onevent> tags are used to create event
handlers.
• Its usage takes the following form:
<onevent type="event_type">
A task to be performed.
</onevent>
WML <onevent> element
The <onevent> element supports the following attributes:
1. Type - can take following values:
a) onenterbackward
b) onenterforward
c) onpick
d) Ontimer
2. Class
3. Id
Example of <onevent> element:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<onevent type="onenterbackward">
<go href="#card3"/>
</onevent>
<card id="card1" title="Card 1">
<p>
<anchor>
<go href="#card2"/>
Go to card 2
</anchor>
</p>
</card>
<card id="card2" title="Card 2">
<p>
<anchor>
<prev/>
Going backwards
</anchor>
</p>
</card>
<card id="card3" title="Card 3">
<p>
Hello World!
</p>
</card>
</wml>
<onenterbackward>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card id="card1" title="Card 1">
<onevent type="onenterbackward">
<go href="#card3"/>
</onevent>
<p>
<anchor>
<go href="#card2"/>
Go to card 2
</anchor>
</p>
</card>
<card id="card2" title="Card 2">
<p>
<anchor>
<prev/>
Going backwards
</anchor>
</p>
</card>
<card id="card3" title="Card 3">
<p>
Hello World!
</p>
</card>
</wml>
Result:
• When you load this program, you will get the following screen:
Result:
• Now, press option Go to card 2 to go to the second card this will
take you to the following screen:
Result:
• Now, you are on second page. Now, when you try to go back on
card number, onenterbackward event is executed and it takes
you on card number 3 instead of card number 2 and you see
the following screen.
<onenterforward> element
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<wml>
<wml>