0% found this document useful (0 votes)
380 views35 pages

Variable, Literals, Control Structure and Functions

The document discusses Wireless Markup Language (WML), which is used to develop applications for mobile devices and is similar to HTML but optimized for smaller screens and lower bandwidth connections, it describes key differences between WML and HTML as well as WML programming structures, elements, and control statements.

Uploaded by

beneyaz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
380 views35 pages

Variable, Literals, Control Structure and Functions

The document discusses Wireless Markup Language (WML), which is used to develop applications for mobile devices and is similar to HTML but optimized for smaller screens and lower bandwidth connections, it describes key differences between WML and HTML as well as WML programming structures, elements, and control statements.

Uploaded by

beneyaz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

WML

Variable, Literals,
Control structure and Functions

1
WML
• WML stands for Wireless Markup Language
• WML is an application of XML, which is defined in a
document-type definition.
• WML is based on HDML and is modified so that it can be
compared with HTML.
• WML takes care of the small screen and the low bandwidth of
transmission.
• WML is the markup language defined in the WAP
specification.
• WAP sites are written in WML, while web sites are written in
HTML.
• WML is very similar to HTML. Both of them use tags and are
written in plain text format.
2
Difference between HTML and WML
• the basic unit of navigation in HTML is a page, while that in
WML is a card. A WML file can contain multiple cards and
they form a deck.
• When a WML page is accessed from a mobile phone, all
the cards in the page are downloaded from the WAP
server. So if the user goes to another card of the same
deck, the mobile browser does not have to send any
requests to the server since the file that contains the deck
is already stored in the wireless device.
• We can put links, text, images, input fields, option boxes
and many other elements in a card.

3
WML Program Structure:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>

<card id="one" title="First Card">


<p> This is the first card in the deck </p>
</card>

<card id="two" title="Second Card">


<p> Ths is the second card in the deck </p>
</card>

</wml>

• One WML deck (i.e. page ) can have one or more cards as shown above. 4
WML Document Prolog
• The first line of this text says that this is an XML
document and the version is 1.0.
• The second line selects the document type and
gives the URL of the document type definition
(DTD).
• The DTD referenced is defined in WAP 1.2, but
this header changes with the versions of the
WML.
• The prolog components are not WML elements
and they should not be closed, i.e. should not
give them an end tag or finish them with />. 5
WML Document Body
• The body is enclosed within a
<wml> </wml> tag pair.
• The body of a WML document can consist of
one or more of the following:
• Deck
• Card
• Content to be shown
• Navigation instructions
6
To develop WAP applications we need the
following
• A WAP enabled Web Server: we can enable our Apache or
Microsoft IIS to serve all the WAP client request.
• A WAP Gateway Simulator This is required to interact to
WAP server.
• A WAP Phone Simulator: This is required to test WAP Pages
and to show all the WAP pages.

We can write our WAP pages using following languages:


Wireless Markup Language(WML) to develop WAP
application.
WML Script to enhance the functionality of WAP application.
7
8
Configuring Web Server

• In normal web applications, MIME type is set to


text/html, designating normal HTML code.
• Images, on the other hand, could be specified as
image/gif or image/jpeg, for instance.
• With this content type specification, the web
browser knows the data type that the web server
returns.
• To make Apache WAP compatible we need to add
support for the MIME types and extensions
mentioned next.
9
File Extension MIME type

WML (.wml) text/vnd.wap.

text/vnd.wap.wmlscript
WMLScript (.wmls)

WMLScriptc (.wmlsx) application/vnd.wap.wmlscriptc

WMLC (.wmlc) application/vnd.wap.wmlc

WBMP (.wbmp) image/vnd.wap.wbmp

10
• WML is defined by a set of elements that
specify all markup and structural information
for a WML deck.
• Elements are identified by tags, which are each
enclosed in a pair of angle brackets.
• Unlike HTML, WML strictly adheres to the XML
hierarchical structure, and thus,
 elements must contain a start tag
 any content such as text and/or other
elements; and
 an end tag.
11
Cont….
• Elements have one of the following two structures:
• <tag> content </tag> : This form is identical to HTML.
• < tag / >
• This is used when an element cannot contain visible
content or is empty, such as a line break. WML
document's prolog part does not have any element
which has closing element.
• Mentioned next table lists the majority of valid
elements.

12
Deck & Card Elements

WML Elements Purpose


<!-->  Defines a WML comment
<wml>  Defines a WML deck (WML root)
<head> Defines head information
<meta> Defines meta information
<card> Defines a card in a deck
Defines information about the access
<access>
control of a deck
<template> Defines a code template for all the cards
in a deck

13
Text Elements

WML Elements Purpose


<br> Defines a line break
<p>  Defines a paragraph
<table> Defines a table
<td> Defines a table cell (table data)
<tr> Defines a table row
<pre> Defines preformatted text

14
Text Formatting Tags
WML Elements Purpose
<b> Defines bold text
<big>  Defines big text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<u> Defines underlined text

Image Elements

Purpose
WML Elements
<img> Defines an image

15
Anchor Elements
WML Elements Purpose
<a> Defines an anchor
<anchor>  Defines an anchor

EVENT ELEMENTS

WML Elements Purpose


<do> Defines a do event handler
<onevent> Defines an onevent event handler
<postfield> Defines a postfield event handler
<ontimer> Defines an ontimer event handler
<onenterforward> Defines an onenterforward handler
<onenterbackward> Defines an onenterbackward handler
<onpick> Defines an onpick event handler

16
Task Elements
WML Elements Purpose
Represents the action of switching to a
<go> new card
<noop> Says that nothing should be done
<prev> Represents the action of going back to the
previous card
<refresh> Refreshes some specified card variables.

Input Elements
WML Elements Purpose
<input>  Defines an input field
<select> Defines a select group
<option> Defines an option in a selectable list
<fieldset> Defines a set of input fields
Defines an option group in a selectable
<optgroup>
list

17
Variable Elements

WML elements Purpose

< setvar > Defines and sets a variable

<timer> Defines a timer

18
Control statements

19
WML Script if...else Statement
• WMLScript's if statement uses the following
syntax.
• The part inside brackets [] is optional. The syntax
is the same as that of C++, Java and JavaScript.
if (condition)
{
WMLScript statement(s)
}
[else { WMLScript statement(s) }]
20
WML Script while Statement

• WML Script's while statement is used to repeat the


execution of a block of statements while a condition is true.
It has the following syntax:

while (condition)
{
WMLScript statement(s)
}

• The statement(s) enclosed in the curly brackets {} will be


executed again and again as long as condition is true.
• The loop stops when condition evaluates to false or invalid.
21
WML Script for Statement
• Like a while loop, a for loop is executed repeatedly as long
as a condition is satisfied.
• If the number of times to be repeated is certain, using the
for statement will be more convenient than using the while
statement.
• The for statement has the following syntax in WMLScript.

for ([expression1]; [expression2]; [expression3])


{
WMLScript statement(s)
}

• The parts enclosed in brackets [] are optional.


22
WML Script break Statement

• The break statement is used to quit a loop.


• It must be put inside while loops or for loops.
• The following WMLScript example demonstrates how to
use the break statement:
var result = 0;
for (var counter=0; counter<10; counter++)
{
break;
result += 5;
}
23
WML Script continue Statement
• The continue statement is used to quit the current iteration of a loop
in WMLScript.
• The next iteration will be started if the loop's conditional expression
evaluates to true.
• The continue statement must be put inside while loops or for loops.
• The following script demonstrates how to use the continue statement:

var result1 = 0; var result2 = 0;


for (var counter=0; counter<10; counter++)
{
result1 += 5;
continue;
result2 += 5;
}
24
Function

25
• We can use the function declaration to declare a
WMLScript function name (Identifier) with the
optional parameters (FormalParameterList) and a
block statement that is executed when the
function is called.
• All functions have the following characteristics:
• Function declarations cannot be nested.
• Function names must be unique within one
compilation unit.
26
Cont…
• All parameters to functions are passed by value.
• Function calls must pass exactly the same number of arguments
to the called function as specified in the function declaration.
• Function parameters behave like local variables that have been
initialized before the function body (block of statements) is
executed.
• A function always returns a value.
• By default, it is an empty string ("").
• However, you can use a return statement to specify other return
values.

function Identifier (FormalParameterList)


{ };

27
examples
• Local script functions

• External functions

• Library functions

28
VariVariabVaVariable statementsriable
statements

29
If statement

30
While, for statements

31
Break, continue statements

32
WML Script Standard Libraries 1/3

• Lang library
– abs, min, max, parseInt, parseFloat, isInt, isFloat,
random, etc.
• Float library
– int, floor, ceil, pow, round, sqrt, maxFloat,
minFloat

33
WML Script Standard Libraries 2/3

• String library
– length, isEmpty, charAt, subString, find, replace,
elements, elementAt, removeAt, replaceAt,
insertAt, trim, compare, toString, format, ...
• URL library
– isValid, getScheme, getHost, getPort, getPath,
getParameters, getQuery, getFragment, getPase,
getReferer, resolve, ...

34
WML Script Standard Libraries 3/3

• WMLBrowser library
– getVar, setVar, go, prev, newContext,
getCurrentCards
• Dialogs library
– prompt, confirm, alert

35

You might also like