- A Brief History of WAP
- WAP Criticism: A Popular Spectator Sport
- New in WAP 2
- WML 2: XHTML Extended
- Tools
- Conclusion
WML 2: XHTML Extended
In WAP 2, WML is no longer a standalone XML language, like its predecessors (WML 1.x); it is now defined as a set of XHTML modules and a WML-specific extension module. First, let's take a look at XHTML, which is a reformulation of HTML 4 within the more constrained syntax of an XML-compliant language. This has an advantage in the mobile device world because well-formed XML markup is easier for parsers to process than HTML (WML 1.x also has this advantage). That means that WAP gateways will be capable of encoding and decoding XHTML in much the same way that they currently process WML. Translation between WML 1 and 2 is also fairly simple. To support backward compatibility, the WAP 2 standards actually specify how this translation should be done; a translating (XSLT) style sheet and Java extension code are provided in the specifications. WAP 2 gateways will most likely provide translating services, allowing newer WML 2 browsers to display WML 1.2 or 1.3 content. It is also possible that high-end devices may be capable of doing this translation on the fly.
Getting back to XHTML, WML 2 is specified as an extended subset of XHTML based mainly on the XHTML Basic modules. One large change from traditional HTML is the modular approach taken by XHTML (as of version 1.1). The XHTML markup definition has been broken up into many modules, each dealing with a distinct aspect of presentation. XHTML Basic is a subset of these modules selected for processing by simple devices (such as wireless handsets). XHTML Basic modules include the following components:
- Structure (html, head, body, and title)
- Text (headers, such as h1; paragraphs, such as p; and emphasis, such as em)
- Hypertext (the anchor element, a)
- List (dl and li)
- Basic forms (form, input, select, and option)
- Tables (table, td, th, and tr)
- Image (img)
WML 2 extends XHTML Basic, adding the XHTML block-level presentation, and CSS style sheet modules. It also adds some WML attributes and elements to XHTML that are named using the "wml" namespace prefix (as in wml:go) to distinguish them from XHTML attributes and elements. It is interesting to note that Nokia, the first WAP vendor to support XHTML in its development products, recommends that developers should not use the WML extensions when writing mobile XHTML. The company states that these extensions are intended to allow gateways and other converters to map older versions of WAP to the newer browsers. Openwave recommends the use of the WML extensions to XHTML as well as its own proprietary mobile extensions. Openwave states that this allows developers to take full advantage of new graphical capabilities in the latest browsers.
So what does a WAP 2 document look like? Listing 1 shows a basic document displaying the partial results of a query on a real estate (multiple listing service) database.
Listing 1: Simple WML2 Page Containing Real Estate Query Results
<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE html PUBLIC"-//WAPFORUM//DTD WML 2.0//EN" "http://www.wapforum.org/dtd/wml20.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wml="http://www.wapforum.org/2001/wml"> <head> <link href="mls.css" type="text/css" rel="stylesheet"/> <title>MLS Query Results</title> </head> <body> <h1>Results</h1> <p align="left"> <i>Single-family</i><br/> 45 Laurentide Dr<br/> Price: 159900<br/> Bungalow<br/> Bdrms: 3<br/> Baths: 1.5<br/> Age: 38<br/> </p> <p align="left"> <i>Single-family</i><br/> 23 Gateway Blvd<br/> Price: 153900<br/> Side-split<br/> Bdrms: 3<br/> Baths: 2.0<br/> Age: 36<br/> </p> <a href="http://www.mls.com/cgi-bin/mls/getQuery.cgi">New Query</a> </body> </html>
Some of the points to note are the document type, the declaration of a default XHTML namespace, and the additional WML namespace. Also new are the use of <html> and <body> tags in place of the <wml> and <card> elements in WML 1.x. An external CSS style sheet is referenced by the <link> element. Note that there are no WML extension tags in this document, allowing it to be rendered by both Web and wireless browsers. The following snippet illustrates how the WML extensions look when used to create a widget for navigating to the getQuery function linked to above:
<wml:do role="positive"> <wml:widget>New Query</wml:widget> <wml:go href="http://www.mls.com/cgi-bin/mls/getQuery.cgi"/> </wml:do>
The role attribute specifies the nature of the event handler. A "positive" role is used for acknowledgement and replaces the "accept" type attribute of WML 1.x. One or more wml:widget elements can be used to define a how this handler should be rendered (as a soft key, inline with the text, or as part of a menu). The widget that we defined above is simply used to provide a label for the event handler. In WML 1.x, this functionality would have been implemented as follows:
<do type="accept" label="New Query"> <go href="http://www.mls.com/cgi-bin/mls/getQuery.cgi"/> </do>
The WML 2 specification (June 26, 2001) is still at the proposal stage, so it is a little too early to provide a full tutorial. Stay tuned for more details in a future article.