Overview of WML Syntax

WML is a markup language based on Extensible Markup Language (XML). XML, like HTML, is a Standardized Generalized Markup Language (SGML) variant. The WAP Forum provides a formal Document Type Definition (DTD) for WML at: http://www.wapforum.org. Two DTDs are referred to throughout this post:

The Openwave DTD includes the Openwave WML 1.3 extensions. You should use this DTD if you plan to use WML 1.3 with Openwave extensions. Otherwise you should use the WAP Forum DTD, which refers to the official WAP Forum WML 1.3 specification. The WML language defines elements and attributes that you use to specify the user interface components, called cards, that users see on their mobile browser device. Just as a web browser can navigate from one page to another, the Openwave Mobile Browser can navigate from one card to another. A card can specify multiple user actions by including one or more of the following:
Formatted text, including text, images, and links
input elements that let the user enter a string of text
select elements that let the user choose from a list of options
fieldset elements that act as organizational containers for other elements

The smallest unit of WML that you can send to a mobile browser device is a deck—one or more cards that a user is likely to access together. When a mobile browser device receives a WML deck, it displays the content defined in the first card and allows the user to respond. Depending on the card definition, the user can respond by entering text or by choosing an option. Mobile browser devices with larger displays typically present each card as a single screen. Some smaller devices present each card as a collection of screens.

NOTE : The Mobile Access Gateway supports a special construct called a digest that you can use to package multiple decks into a single HTTP response.

The high-level syntax for defining a WML deck is as follows:
access control and meta information
deck-level event bindings
card-level event bindings

Basic Elements in WML syntax :
<wml> : Required. The <wml> element specifies a deck.
<head> : The <head> element specifies information about the deck as a whole, including metadata and access control information. All WML decks are private by default, you must explicitly define a deck as public for cards or decks outside your domain to access it.
<template> : The <template> element defines deck-level event bindings characteristics that apply to all cards in the deck. You can override these characteristics for a particular card by specifying the same event bindings within the <card> element.
<card> : Required. One or more <card> elements define the actions and user interface for the deck. A card can contain the following components:
• Formatted text, which can include text, images, and links
• <input> elements, which allow the user to enter a string of text
• <select> elements, which allow the user to choose from a list of options
• <fieldset> elements, which act as organizational containers for other elements

Most WML elements have one or more attributes, some of which are optional. Use attributes to specify additional information about how the device should handle the element. Although the exact syntax of a WML statement depends on whether or not the element has content, attributes always appear in the element start tag:
<element a1=”value1″ a2=”value2″ …> content </element>
<element a1=”value1″ a2=”value2″ …/>
You must enclose attribute values within single (‘) or double (“) quotation marks and separate each attribute-value pair with white space (space, tab, newline, or carriage return character). White space is not allowed, however, between the attribute name, equal sign, and attribute value. Like HTML, WML uses the printable 8-bit character set and converts one or more contiguous newlines, carriage returns, tabs, or spaces to a single space. Unlike HTML, WML is case-sensitive, all WML elements and attributes must be lowercase. The examples in this manual use newlines and tabs for readability, but this formatting is not required. In fact, the Mobile Access Gateway removes it before sending the WML to the phone. You can also include comments in your WML code using the following syntax:
<!– This is the first line of my comment. –>
<!– This is the second line of my comment. –>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.