|
Introducing WML By Steve Heckler
WAP is the protocol that lets your mobile phone or other wireless device communicate with your provider’s gateway. That gateway, in turn, retrieves content from servers using HTTP, the same protocol that standard Web browsers use. For example, if you're a customer of Sprint PCS, each time you launch your phone’s minibrowser you're connecting to Sprint’s WAP gateway which fetches content when your minibrowser requests it (see figure below).
Almost all WAP browsers are made by either Nokia (for Nokia phones) or Phone.com. Both firms offer emulators for their WAP browsers, which developers can run on standard PCs. Nokia’s WAP Toolkit is written in Java and runs on most platforms. Phone.com’s UP.SDK (software development kit) is a native application available on several platforms.

Understanding the WAP browser interface
Users navigate WAP sites using three tools:
- Navigation arrows that let users move the cursor up and down within the current screen.
- Left and right soft buttons that let users select a hyperlink, display a menu of choices, or perform other actions specified by WML code. The current action for a soft button displays as a label above that button.
- Keypad lets users enter text.

Decks and cards
Each screen displayed on the phone is referred to as a card. Cards are saved in groups known as decks. Those decks are stored in .wml files, with one deck per file. When the user selects a link, one of two actions usually occurs:
- A new card in the current deck is brought to the foreground. That happens instantaneously because the entire deck is already in memory and no communication with the server is required.
- A new deck is loaded and one of its cards is displayed. The deck may be from the current server or another server. That typically takes a few seconds because the latency of wireless Internet connections is typically high.
The origins of WML
Most modern markup languages trace their development to Structured Generalized Markup Language, which became popular in the 1980s as a document storage format. SGML directly spawned many other markup languages, including HTML and XML.
HTML, which is the language most often used for building Webpages, has two major flaws: inadequate structured format data storage and tolerance of such erroneous coding as unclosed tags, optional quotation marks, and lack of enforcement for case sensitivity.
In contrast, XML, which is designed explicity for storing data, insists on strict, proper syntax. More important, XML provides two syntaxes--DTDs (Document Type Definitions) and Schemas--that define new markup XML-based languages. For instance, XHTML is HTML that conforms to XML syntax rules. XHTML will eventually replace HTML as the standard language for building Web pages. Another new XML-based language is WML. The DTD for WML was released in 1998 and is maintained by the WAP forum (www.wapforum.org).
Designing for the WAP user interface
The WAP medium differs from standard Web interface in the following ways:
- Sites are designed for low-bandwidth conditions and use minimal graphics because standard mobile phones display 96x64 pixels with one-bit black and white graphics.
- Sites are broken across multiple cards, with each card short enough to be read quickly.
- Soft buttons must have short, clear labels that work instantly.
- The back button is not automatically available and the developer must code it as a soft button.
- Sites must be designed for easy bookmarking.
- Sites tend to be menu driven rather than text-entry driven.
- Sites are usually extensions of traditional Websites. For example, http://wap.yahoo.com lets users access information that they've requested via their Web-based My Yahoo! account, including theater show times, stock quotes, weather, and sports scores. Expedia’s WAP service lets its Web-based service users access scaled-down information via their mobile phones, including flight times and hotel reservations.
WML basics
Please examine the following card:

<?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="main" title="An Example"> <p>Hello World </p> </card> </wml>
The first line, <?xml version="1.0"?>, is the standard first line in all XML files or files that are derived from XML. It indicates that the code conforms to version 1.0 of the XML specification.
The next line, <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">, specifies the XML document type as wml. The PUBLIC attribute identifies that the DTD for this document is available on the Web rather than a system DTD housed on the current server. The final attributes identify the WML language version specification and the URL where its corresponding specification can be found.
The code <wml>…</wml> encloses the rest of the deck's code in the same manner that <html>…</html> does in HTML documents .Inside <wml>…</wml> there will be code for one or more cards; each card is enclosed by <card>…</card>. In this example, we have specified an id for the card and a title: <card id="main" title="An Example">. The id is a required attribute that specifies a unique name for the card. Unique IDs hyperlink to point within a specific card, rather than to the entire deck. The title is optional and isn't displayed by most browsers, but browsers’ bookmarking features use it frequently. Other attributes include
| Attribute |
Definition |
| newcontext (true/false) |
Specifies whether the device should erase all previous variables values prior to displaying the card |
| ordered (true) |
Specifies whether the items on the card will be displayed in a linear sequence |
| onenterforward |
Specifies the URL to display if the user enters the card in the forward direction, such as selecting a link |
| onenterbackward |
Specifies the URL to display if the user enters the card in the backward direction, such as clicking the Back button |
| ontimer |
Specifies the URL to load if a timer embedded within the card expires |
All text within the card must be enclosed by <p>…</p> for standard paragraphs or <a>…</a> for hyperlinks.The tag accepts two attributes:
| Attribute |
Definition |
| align (left/center/right) |
Horizontal alignment of text within the paragraph |
| mode (wrap/nowrap) |
Specifies whether text wraps automatically, which is almost always a good idea. Note that the mode set for one paragraph automatically applies as a default to all subsequent paragraphs within the card. |
Complex WML formatting
Please examine the following card:
<?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="home" title="SMPU"> <p align="center"> <big>SMPU</big><br /> <small><i>Society of Mobile Phone Users</i></small><br /> </p> <p> About SMPU<br /> Become a Member<br /> Find an Event<br /> Locate a Chapter<br /> </p> </card> </wml>
The tags within the paragraphs perform the same functions as they would in basic HTML. The code <big>…</big> and <small>…</small> let the developer control font size, but are rarely displayed by the current generation of browsers.
The <br /> tag inserts a line break. Please note that this element can be written as <br></br> or<br />. The <br /> version is simple short-hand for the first, with the trailing slash indicating that the element is closed immediately after it is opened. Although the <br> tag can exist without a corresponding close tag in HTML, the <br> tag (and all tags) must be closed in XML.
Also, WAP devices only support wireless bitmaps graphics with the file extension .wbmp. The WBMP format supports up to two bits per pixel. Each pixel displays as white, black, or two intermediate shades of gray, but many WAP browsers display graphics only in black and white. Most modern graphics programs now have add-ons for saving graphics as WBMPs. In addition, numerous WBMP clipart libraries can be found at such Websites as www.hicon.nl.
WML follows XML rules
For WML code to be valid, it must conform to all XML tagging rules. 1. Tags must be nested. For example, <b><i>Hello</i></b> is valid syntax, as opposed to <b><i>Hello</b></i>.
2. Tags must be closed. For example, consider the code for creating new paragraphs and line breaks. The code <p> <br /> </p> is valid syntax. The code <p> creates a pragraph, <br /> creates and closes a line, and </p> closes out the paragraph. But <p> <br> </p> isn't valid syntax because the <br> code is never closed.
3. Tags are case sensitive and must be written in all lowercase. This is in sharp contrast to HTML, which is case insensitive.
4. All attribute values must be in quotes. For example, <p align="center"> is valid syntax, but <p align=center> is invalid because it's missing quotation marks around the center attribute.
Working with multiple cards and hyperlinks
WML lets developers include multiple cards within a single deck. Because the browser downloads the entire deck prior to displaying the first card, a link to another card will display immediately without the server having to be contacted.
Please examine the following card:

The first link points to another card within the same deck, but the other links point to other decks.
The source code for the deck is as follows:
<?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="home" title="SMPU"> <p align="center"> <big>SMPU</big><br /> <small><i>Society of Mobile Phone Users</i></small><br /> </p> <p> <a href="#about">About SMPU</a><br /> <a href="become-simple.wml">Become a Member</a><br /> <a href="event-simple.wml">Find an Event</a><br /> <a href="chapter-simple.wml">Locate a Chapter</a><br /> </p> </card> <card id="about" title="About SMPU"> <p> SMPU was founded by a group of devoted mobile phone users in 2001 to promote the responsible use of mobile phones. Today, chapters can be found throughout the world. </p> <p> <a href="#home">SMPU Home</a> </p> </card> </wml>
The first card is named SMPU; the second card is named about. Within the first card, clicking on the link <a href="#about">About SMPU</a> results in the about card being pushed to the foreground.
Bottom line
In the year 2000 wireless access to the Internet from mobile devices became mainstream. Approximately half of the mobile phones sold were equipped with WAP (wireless application protocol) browsers that supported content which consisted exclusively of text that was written in wireless markup language and had a maximum throughput of 19.2Kbps. However, OmniSky, GoAmerica, and other companies introduced wireless modems for personal digital assistants that delivered text and limited graphics using standard HTML Web pages. Also using standard HTML, Metricom and some other firms introduced wireless Internet access for laptops that had 128Kbps wireless access.
So, be on the lookout in 2001, for wireless e-learning coming to a PDA near you.
Published: February 2001
|