|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TODAY'S TOP SOA & WEBSERVICES LINKS Feature Wireless Markup Language
Wireless Markup Language
By: Ian Moraes
Feb. 28, 2000 12:00 AM
The ability to access Web content and send e-mail messages from a wireless phone has become a requirement for the rapidly growing segment of wireless Internet users. Application development for wireless devices can be more challenging than conventional Web development due to the inherent characteristics of wireless devices - small display areas, narrow bandwidth connections, limited means for user input and limited memory resources. In addition, there are disparate vendor-specific wireless devices and presentation mechanisms. To address some of these issues, the Wireless Application Protocol (WAP) Forum has defined a standard for the presentation and delivery of information to, for example, wireless phones, pagers and personal digital assistants (PDAs). The Wireless Markup Language (WML) is a specification of the WAP Forum pertaining to the presentation of content and user interface behavior on wireless devices. WML was designed to accommodate presentation on limited-capacity devices such as wireless phones. WML is an XML language that inherits the XML document character set and most of the XML syntax. The document character set for WML is the Universal Character Set that is currently identical to Unicode 2.0. WML is specified as an XML document type definition (DTD), and is supported on any device that is WAP compliant. This article focuses on using WML for delivering content for presentation on WAP-compliant wireless devices. Before I discuss WML, I think an overview of the WAP development model will be helpful. WAP programming is based on the Web programming paradigm. The model, as shown in Figure 1, comprises three major components. The client component of the model is a WAP user agent that can interpret WML and present WML content to a user in a form appropriate for that type of wireless device. As its name implies, a WAP gateway converts to and from the wire-based and wireless domain, translating requests and responses from the TCP/IP protocol stack to the WAP protocol stack and vice-versa. It translates Web content into compact, encoded formats to increase transmission efficiency over the wireless network. WML can be encoded using a scheme based on the WAP Binary XML Content Format. A WAP gateway is required to access WML content over the Internet using HTTP requests. The server component of the model consists of a Web server, servlets and/or CGI scripts that generate WML content in response to requests. Now that you're familiar with how WML fits into the overall WAP environment, we can begin to discuss the WML syntax.
WML Essentials
In WML, an element describes markup information about a deck. An element may be of two forms: <tag>content</tag> or </tag>. table 1 summarizes some typically used WML elements.
Most WML elements have attributes that let you specify additional information about how a WAP device should interpret an element. All attribute values must be enclosed within single (') or double (") quotation marks. Character entities can be included in attribute values. WML supports both named character entities and numeric character entities. WML entities represent specific characters in the document character set. For example, the named entity & is used to represent the ampersand character (&). Note that, like XML and unlike HTML, WML is case sensitive.
A valid deck is a valid XML document; thus a valid deck must be composed of an XML declaration and a document-type declaration. The high-level syntax for defining a WML deck is shown below. All cards in a deck are defined within the
<?xml version="1.0"?>
<card>
Examples
Since the focus of this article is WML, only WML code will be used to develop the presentation component (View) of an e-mail client application for mobile devices. The Model and Controller components of this type of application (e.g., servlets, Enterprise JavaBeans) won't be discussed. However, at the end of this article there is a reference to a recent article on JavaMail that discusses how e-mail client functionality can be supported.
The code shown here was developed using the UP.SDK, which provides a WAP development environment. The toolkit includes a phone simulator with a browser that supports WML. SDKs that support development using WML can be downloaded from the sites listed in the Reference section of this article.
Login to E-Mail Server
A number of WML elements are needed to support this use case. The <input> element has a name attribute that specifies the variable that a device uses to hold user input. This element also has a type attribute that masks the password (replaces the characters by asterisks) being input. The href attribute of the <go> element is used to specify navigation to a servlet for processing the user login while the method attribute of the <go> element specifies the HTTP submission method (post). The <postfield> element passes the login name and password to the HTTP server receiving the <go> request. The value attribute of the postfield element in the code below uses WML variables. For example, the value of the WML variable $pwd is substituted at runtime with the actual password entered by the user. A code snippet for entering the user ID and password is given below. A more complete code listing is shown in Listing 1.
<do type="accept">
A simulated wireless device presentation and navigation of the two WML cards defined in Listing 1 that allows a user to log in to an e-mail system is displayed in Figure 2.
Main Menu of E-Mail Client
<card id="main">
A display of the presentation of this WML card, showing a user e-mail menu choices, is shown in Figure 3.
The WAP phone simulator used for development has a programmable soft key. The <do> element is used to map an action to a soft key. The href attribute of the <go> element is used to specify navigation to the next card to be displayed. A code snippet from the first card used to send an e-mail message is shown below. A more complete code listing for sending an e-mail message is shown in Listing 2.
<do type="accept" label="ok">
WAP client validation of user input is an important consideration, given the inherent limitations of wireless devices. WMLScript could be used to validate user input such as an e-mail address before it's sent to a servlet for further processing. For those who have used HTML scripts, WMLScript is a procedural scripting language based on ECMAScript and adapted to suit the needs of wireless devices.
Conclusion
References XML JOURNAL LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING XML NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||