Unit Iii
Unit Iii
Variables – Other Content you can Include – Controls – Miscellaneous Markup – Sending
Information – Application Security – Other Data: The Meta Element – Document Type-
Declarations – Errors and Browser Limitations – Content Generation – WML Version
Negotiation.
UNIT III
Variables:
Variables allow you to alter your content dynamically at run time. Variables are considered
set if they contain any value other than the empty string.
The syntax of accessing the value of a variable is the U.S. dollar sign followed by the
variable’s name in parentheses: $(user name). If the variable reference is followed by
whitespace, you can omit the parentheses:
Your name is $first $(last).
Variables can be created and set using several different methods. Following are two examples:
The following element would create a variable named a with a value of 1000:
<select name="b">
</select>
Using Variables:
Variable expansion occurs at runtime, in the microbrowser or emulator. This means it can be
concatenated with or embedded in other text.
Variables are referenced with a preceding dollar sign, and any single dollar sign in your WML
deck is interpreted as a variable reference.
Intial Variable
<setvar name="var1" value=""/>
Other content you can include
WML documents may include several other types of content, including images, tables, and links.
Images:
As in HTML, decks cannot images directly; instead, they can include references to images,
which exits in separate files.
A picture may be worth a thousand words, but no matter how they are presented, no one
wants to read a thousand words on a four-line screen.
The <img> element is used to include an image in a WAP card. WAP-enabled wireless devices
only supported the Wireless Bitmap (WBMP) image format.
WBMP images can only contain two colors: black and white. The file extension of WBMP is
".wbmp" and the MIME type of WBMP is "image/vnd.wap.wbmp".
middle
bottom
alt alternative text Sets an alternate text to be displayed if the image is not
displayed.
hspace px Sets white space to the left and right of the image. If you
specify the value in pixels, the syntax is "140", instead of
% "140px".
vspace px Sets white space above and below the image. If you
specify the value in pixels, the syntax is "140", instead of
% "140px".
width px Sets the width of the image.If you specify the value in
pixels, the syntax is "140", instead of "140px".
%
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<p>
This is Thumb image
</p>
<p>
</p>
</card>
</wml>
T Tables:
WML support simple tables for organizing content into columns. These tables are not intended to
provide fancy formatting—bear in mind the small size of the screen that most devices will use.
Table data is organized into rows, specified with the tr (table row) element; rows, in turn, contain
cells indicate by td (table data) elements.
The <table> element along with <tr> and <td> is used to create a table in WML. WML does not
allow the nesting of tables
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<p>
<tr>
<td>Col 1</td>
<td>Col 2</td>
<td>Col 3</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</table>
</p>
</card>
</wml>
WML – Links
Links:
HTML standardized an unfortunate overloading of the term anchor, applying it not only to the
point in the document that activates the link.
A WML link is a connection between a document hotspot and a task. This task might be a
navigation task (mimicking HTML links) but could also be a prev or refresh task.
WML provides you an option to link various cards using links and then navigate through
different cards.
There are two WML elements, <anchor> and <a>, which can be used to create WML links.
You can enclose Text or image along with a task tag inside <anchor>...</anchor> tag pair.
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<anchor>
<go href="nextpage.wml"/>
</anchor>
</p>
<p>
<anchor>
<prev/>
</anchor>
</p>
</card>
</wml>
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
</p>
</card>
</wml>
Attributes:
This element supports the following attributes:
Example:
Following is the example showing usage of this element.
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
</p>
</card>
</wml>
name text The name of the variable that is set with the result of the user's
input
maxlength number Sets the maximum number of characters the user can enter in the
field
emptyok true Sets whether the user can leave the input field blank or not.
false Default is "false"
format A Sets the data format for the input field. Default is "*M".
a A = uppercase alphabetic or punctuation characters
N a = lowercase alphabetic or punctuation characters
X N = numeric characters
x X = uppercase characters
M x = lowercase characters
m M = all characters
*f m = all characters
nf *f = Any number of characters. Replace the f with one of the
letters above to specify what characters the user can enter
nf = Replace the n with a number from 1 to 9 to specify the
number of characters the user can enter. Replace the f with one
of the letters above to specify what characters the user can
enter
tabindex number Sets the tabbing position for the select element
type text Indicates the type of the input field. The default value is "text".
password Password field is used to take password for authentication
purpose.
value text Sets the default value of the variable in the "name" attribute
iname text Names the variable that is set with the index result of the
selection
name text Names the variable that is set with the result of the
selection
tabindex number Sets the tabbing position for the select element
value text Sets the default value of the variable in the "name" attribute
xml:lang language_code Sets the language used in the element
<wml>
</wml>
When you will load this program, it will show you the following screen:
Once you highlight and enter on the options, it will display the following screen:
You want to provide option to select multiple options, then set multipleattribute to true as
follows:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card title="Selectable List">
<p> Select a Tutorial :
<select multiple="true">
<option value="htm">HTML Tutorial</option>
<option value="xml">XML Tutorial</option>
<option value="wap">WAP Tutorial</option>
</select>
</p>
</card>
</wml>
This will give you a screen to select multiple options as follows:
Miscellaneous Markup:
The timer element lets you trigger an event after a certain amount of time has elapsed. The
fielded element lets you group fields into logical collection.
WML <timer> Tag
A timer is declared inside a WML card with the <timer> element. It must follow the <onevent>
elements if they are present. (If there are no <onevent> elements, the <timer> must be the first
element inside the <card>.) No more than one <timer> may be present in a card.
Attributes:
This element supports the following attributes:
Attribute Value Description
value number Specifies the timer after which timer will be expired. Timeouts
are specified in units of a tenth of a second.
<wml>
<card id="splash" title="splash">
<onevent type="ontimer">
<go href="#welcome"/>
</onevent>
<timer value="50"/>
<p>
<a href="#welcome">Enter</a>
</p>
</card>
</wml>
When you load this program it shows you following screen:
If you do not select given Enter option then after 5 seconds you will be directed
to Welcome page and following screen will be displayed automatically.
Sending information:
You cannot write very interesting applications without some means of sending the user’s input to
your application server. “get” and “post”.
Get versus Post
The “get and “post” methods differ in the number of connection that they make to the server
and in the amount of data that can be transferred.
With “get”, the browser sends the data as part of the document request by appending the data to
the URL that it sends to the server.
WML <postfield> Tag
The <postfield> tag is used to post variables values to the server.
Attributes:
This element supports the following attributes:
Attribute Value Description
<wml>
</wml>
When you download above code on your WAP device, it will provide you option to enter three
fields name, age and sex and one link Submit Data. You will enter three fields and then finally
you will select Submit Data link to send entered data to the server.
Application Security:
Data security is as critical in the wireless world as it is on the World Wide Web. For, true
security, WAP defines the WTLS protocol to provide encrypted, authenticated communications.
WML and WMLScript provide “application-level” security, allowing you to prevent
unauthorized decks from linking to yours.
WAP browsers also support the standard Basic Authentication mechanism used on the Web
today.
The <access> element provides a simple form of access control for a deck. This allows a deck
to specify that only certain other decks may link to it (these decks are known as referring
URLs).
There may be no more than one <access> element in a deck, and it must be the first thing inside
the <head> element.
Attributes:
The <access> element supports the following attributes:
Attribute Value Description
domain cdata Specifies the domain (effectively, the range of servers) from which
the referring deck must come.
path cdata Specifies the path within the referring URL that must match. (The
path is the part of the URL that specifies a file or directory on the
server.)
forua true If present and set to true, indicates that the property is
false intended for the use of the browser.
scheme string Can specify a format or structure that some properties may
need to interpret their values. This attribute is used by few
properties.
<head>
<meta name="keyword" content="WML"/>
<meta http-equiv="Cache-control" content="no-cache"/>
</head>
<wml>
<?xml version="1.0"?>
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card>
...
</card>
...more cards...
</wml>
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 DOCTYPE declaration specifies the name of the DTD (Document Type Definition) and the
URL to the DTD. The DTD contains information about the syntax of the markup language. It
defines what elements and attributes can be used in the markup and the rules that they should be
used.
It should be placed between the XML declaration and the <wml> element. Below is the
DOCTYPE declaration for WML 1.
Most of the new mobile phone models released are WAP 2.0-enabled. Because WAP 2.0 is
backward compatible to WAP 1.x, WAP 2.0-enabled mobile devices can display both XHTML
MP and WML documents.
WML 1.x is an earlier technology. However, that does not mean it is of no use, since a lot of
wireless devices that only supports WML 1.x are still being used. Latest version of WML is 2.0
and it is created for backward compatibility purposes. So WAP site developers need not to
worry about WML 2.0.