Images

WAP / WML - PART III


WAP/WML
WML (Wireless Markup Language) is the new web language for making sites on mobile phones.
Over the past few months new WAP (Wireless Applications Protocol) phones have become extremely popular and many large websites have created special 'mobile' versions of their site.
Many people predict that, over the next few years, WAP sites will become even morepopular and e-commerce over mobile phones will be widely available.
Wireless Markup Language(WML) based on XML, is a content format for devices that implement the Wireless Application Protocol (WAP) specification, such as mobile phones, and preceded the use of other markup languages now used with WAP, such asXHTML and even standard HTML (which are gaining in popularity as processing power in mobile devices increases).



Other WML Tags
<head> Tag
The head tag serves as a container element for information on access control and meta-data that applies to the entire deck (the collection of all cards). The access control information is contained in the access element. The meta-data information is contained in the meta element.
Nested Tags: access meta
Attributes
class:
The optional class core attribute is used to assign one or more classes to the element. Multiple classes are separated by white space.
id:
The optional id core attribute is used to assign an identifying name to a tag. The name must be unique to the entire deck and not just unique to a card. The first character of the name can be any letter or the underscore. The remaining characters can be any combination of letters, numbers, or underscores.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<head>
   <access domain="education.ebizel.com">
   <meta name="keyword" content="WML, WAP, WML Tutorial, 
WAP Tutorial, WML Tutorial with examples" />
   <meta name="author" content="eBIZ Education Team" />
</head>

Other WML Tags
<noop> tag
The noop tag dictates that no operation should be done. This tag can be used on the card level to prevent an event, specified on the deck level by the template element, from occurring.
This is referred to as a noop task. A task is performed in response to an event. There are four tasks in WML: go, noop, prev, and refresh. It can only be contained in either a do or onevent element. This is a self-closing tag.
Nested Tags: None
Attributes
class
The optional class core attribute is used to assign one or more classes to the element. Multiple classes are separated by white space.
id
The optional id core attribute is used to assign a unique name to a tag. The name must be unique to the entire deck and not just unique to a card. The first character of the name can be a letter or the underscore. The remaining characters can be any combination of letters, numbers, or underscores.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
    
    <template>
        <do type="prev" label="PREVIOUS">
            <prev />
        </do>
    </template>
    
    <card id="card1" title="Card 1">
        <p>
            <a href="#card2">
                Next-->>></a>
        </p>
    </card>
    
    <card id="card2" title="Card 2">
        <p>
            <do type="prev">
                <noop />
            </do>
            <<--BACK </p>
    </card>
    
</wml>
Output:
card1card2
Card 1Card 2

Other WML Tags
<onevent> Tag
The onevent tag serves as a container for code that you wish to be executed automatically when one of the four intrinsic events occurs. The onevent element is said to bind (associate) the tasks (code) to the event for the element. You must specify the intrinsic event by using the mandatory type attribute.
The four intrinsic events are:
EventPermitted TagsDescription
onenterbackwardcard ortemplateOccurs when a prev navigates back into a card
onenterforwardcard ortemplateOccurs when a go navigates into a card
onpickoptionOccurs when an item is selected or unselected by a user
ontimercard ortemplateOccurs when the timer expires
Note: The template element creates code that is inserted into all cards in a single deck.
Nested Tags: go noop prev refresh
Attributes
class
The optional class core attribute is used to assign one or more classes to the element. Multiple classes are separated by white space. The class name is case sensitive (i.e., Stocks and stocks are not the same).
id
The optional id core attribute is used to assign a unique name to a tag. The name must be unique to the entire deck and not just unique to a card. The first character of the name can be a letter or the underscore. The remaining characters can be any combination of letters, numbers, or underscores.
type
The mandatory type attribute specifies the name of the type of the event.
There are four permitted values: onenterbackward, onenterforward, onpick, and ontimer.

Other WML Tags
WML Table Tag
To create tables and place some data in them, you need the <table>, <tr> and <td> WML tags. A table (<table>) has a number of rows (<tr>) and each row has a number of cells (<td>). Data is placed in table cells.
The markup structure should be like this:
<table>
<tr> <td>Data is placed here</td> </tr>
</table>
The columns attribute of the <table> tag specifies the number of columns of a table. It is a mandatory attribute. The columns attribute value must match the number of <td></td> tag pairs in a row. For example, if the columns attribute value is 3, then each <tr></tr> must contain three <td></td> tag pairs.
The following WML example demonstrates how to create tables and place data in table cells:
<?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="WML Table example">
        <p>
            <table>
                <tr>
                    <td><b>Name</b></td>
                    <td><b>Address</b></td>
                </tr>
                <tr>
                  <td>John</td>
                <td>Rohni</td>
                </tr>
                <tr>
                    <td>Tamanna</td>
                    <td>Noida</td>
                </tr>
            </table>
        </p>
    </card>
</wml>
Output:
card1
Text Alignment in Tables
WML allows you to set the horizontal text alignment of a column in a table. The align attribute of the <table> tag is used for such purpose. Now let's say your table has three columns. To specify the horizontal text alignment of the columns, you need to assign three letters to the align attribute. Each letter represents the horizontal text alignment of a column. The letter can be L, C, or R. Their meanings are shown in the following table:
Letter
Meaning
LLeft alignment
CCenter alignment
RRight alignment
If you want the following settings to be applied to your table:
• First table column -- Left-aligned
• Second table column -- Center-aligned
• Third table column -- Right-aligned
Then you should set the value of the align attribute to LCR.
Example:
<?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="WML Table example">
        <p>
            <table columns="2" align="LR">
                <tr>
                    <td><b>Name</b></td>
                    <td><b>City</b></td>
                    
                </tr>
                <tr>
                  <td>John</td>
                <td>Rohni</td>
            
                </tr>
                <tr>
                    <td>Tamanna</td>
                    <td>Noida</td>
                   
                </tr>
                
                <tr>
                    <td>Tanu</td>
                    <td>Noida</td>
                
                </tr>
            </table>
        </p>
    </card>
</wml>

Other WML Tags
The <timer> Tag
The timer tag serves as a timer clock for a card. The timer is started when the card is entered and stops when you exit the card. You can have only one timer element per card.
You can preset the timer to an amount of time in 1/10th second (decisecond) intervals (i.e., 10 deciseconds is 1 second). Once the timer has spent that amount of time in the card, you can specify an event to occur, such as going to a different card or deck. This permits you to handle inactivity or idle time on a site. (The timer counts down to zero starting from the specified time value.)
This tag may be used with the card, onevent, and template elements. Both the card and template tags have ontimer attributes. The onevent tag uses the type attribute set to "ontimer".
Attributes of <timer>
class
The optional class core attribute is used to assign one or more classes to the element. Multiple classes are separated by white space. The class name is case sensitive (i.e., Stocks and stocks are not the same).
id
The optional id core attribute is used to assign an identifying name to a tag. The name must be unique to the entire deck and not just unique to a card. The first character of the name can be any letter or the underscore. The remaining characters can be any combination of letters, numbers, or underscores.
name
The optional name attribute provides the name of a variable that can have a value assigned to it or can assume the value specified by the value attribute.
value
The mandatory value attribute is an integer number used to set the amount of time in 1/10th second (decisecond) intervals for the timer (i.e., 10 deciseconds is 1 second). If a variable has been named in the name attribute, the number set by the value attribute becomes the default value for that variable. If the named variable already has a value assigned to it, then this attribute is ignored.
Example:
Source code of timer.wml:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//DTD"
 "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
    <card id="card1" title="WML Timer example" ontimer="#card2">
        <timer name="timer1" value="60" />
        <p>
            <b>You will be forwaded  to the next section in <i>6 second(s)</i>.</b>
        </p>
    </card>
    <card id="card2" title="Timer & ontimer Example">
        <p>
            Forwarded from Card 1 by Timer.
        </p>
    </card>
</wml>
Output:
card1card2

Other WML Tags
<refresh> Tag
The refresh tag is used to update the current display. In other words, whatever card is currently being displayed will be refreshed. This is referred to as a refresh task. A task is performed in response to an event. There are four tasks in WML: go, noop, prev, and refresh.
The refresh tag can only be nested inside an anchor, do, or onevent element. This tag can contain one or more setvar elements which are used to set new values for named variables.
Nested Tags: setvar
Attributes
class
The optional class core attribute is used to assign one or more classes to the element. Multiple classes are separated by white space. The class name is case sensitive (i.e., Stocks and stocks are not the same).
id
The optional id core attribute is used to assign an identifying name to a tag. The name must be unique to the entire deck and not just unique to a card. The first character of the name can be any letter or the underscore. The remaining characters can be any combination of letters, numbers, or underscores.

Other WML Tags
<setvar> Tag
A major difference between WML and HTML is that WML has build-in support of variables. You can assign a value to a variable or output the value of a variable in WML without involving any scripting languages. To use variables in HTML, a client-side scripting language (e.g. JavaScript and VBScript) is required.
Setting Variable Values in WML
In WML, variables do not have to be declared explicitly. You can choose a variable name you like and assign a value to it directly. If you read a variable without assigning a value to it earlier, you will obtain an empty string.
Variable names in WML are case-sensitive. The first character of a variable name must be a letter or an underscore. The rest of the characters can be letters, numbers or underscores. Other characters, such as punctuations, are not permitted.
All variables are stored as string. They have a global scope, which means once you have set the value of a variable, you can read it in any cards and decks.
You can set the value of a variable in the following ways:
1. Using the <setvar/> tag
2. Using data collection tags <select> and <input/>
3. Using the setVar() function of WMLScript's WMLBrowser standard library
Setting a value to a variable using the <setvar/> tag is simple. The <setvar/> tag has two attributes, name and value. The name attribute defines the variable name and the value attribute defines the variable value. The following WML code assigns the value WML Tutorial to a variable called var1:
<setvar name="var1" value="WML Tutorial"/>
The <setvar/> tag should be enclosed in the following tags: <go></go>, <prev></prev>, <refresh></refresh>. For example, let's say you want to assign a value to a variable when a user follows an anchor link to a certain card, you should write something like this:
<anchor>
<go href="tutorial_2.wml">
<setvar name="last_tutorial" value="WML Tutorial"/>
</go> Go to next tutorial
</anchor>
If you want to assign a value to a variable when a user clicks an anchor link but you do not want the WAP browser to leave the current card, you need to use the <refresh> tag instead of the <go> or <prev> tag. Here is a WML example that demonstrates how to use the <refresh> tag:
<anchor>
<refresh>
<setvar name="last_tutorial" value="WML Tutorial"/>
</refresh> Refresh variable
</anchor>
If you click the above anchor link, the value of the variable last_tutorial will be set to WML Tutorial.

0 comments: