WML2.0 Tutorial

Advertisements


WML2 is a language, which extends the syntax and semantics of the followings:

  • XHTML Basic [ XHTMLBasic ]
  • CSS Mobile Profile [ CSSMP ]
  • Unique semantics of WML1.0 [ WML1.0 ]

WML2 is optimised for specifying presentation and user interaction on limited capability devices such as mobile phones and other wireless mobile terminals.

This tutorial gives detail of the Wireless Markup Language (WML) Version 2. This tutorial refers to version 2.0 of WML as WML2.

The XHTML Basic defined by the W3C is a proper subset of XHTML, which is a reformulation of HTML in XML.

Basic Goals of WML2:

There are five major goals for WML2:

  • Backward compatibility: WML2 application should be running on old devices as well.

  • Convergence with existing and evolving Internet standards: XHTML Basic [XHTMLBasic] and CSS Mobile Profile [CSSMP]

  • Optimisation of access from small, limited devices: WAP-enabled devices are generally small and battery operated and they have relatively limited memory and CPU power. So WML2 should be optimized enough to run on these devices.

  • Allowance for the creation of distinct user interfaces: WAP enables the creation of Man Machine Interfaces (MMIs) with maximum flexibility and ability for a vendor to enhance the user experience.

  • Internationalisation of the architecture: WAP targets common character codes for international use. This includes international symbols and pictogram sets for end users, and local-use character encoding for content developers.

WML2 Vision:

The WML2 vision is to create a language that extends the syntax and semantics of XHTML Basic and CSS Mobile profile with the unique semantics of WML1. The user should not be aware of how WML1 compatibility is achieved.

The WML2 Language Structure:

WML2 is a new language with the following components:

(1) XHTML Basic:

This element group is for W3C convergence. For some of the elements, WML extension attributes are added in order to achieve WML1 functionality.

(1a) XHTML Basic elements:

a abbr acronym address base blockquote br caption cite code dd dfn div dl dt em form h1 h2 h3 h4 h5 h6 head kbd label li link object ol param pre q samp span strong table td th title tr ul var

(1b) XHTML Basic elements with WML extension attributes:

body html img input meta option p select style textarea

(2) XHTML Modularization elements:

This element group consists of select elements from those modules of XHTML not included in XHTML Basic. Most elements are included for WML1 compatibility. One element is included as an enhancement that fits limited handset capabilities.

(2a) XHTML Modularization for backwards compatibility with WML1:

b big i small (from Presentation Module) u (from Legacy Module) fieldset optgroup (from Forms Module)

(2b) XHTML Modularization elements for feature enhancement:

hr

(3) WML extensions elements:

Some elements are brought from WML1, because the equivalent capabilities are not provided in XHTML Basic or XHTML Modularization. One element is included for enhancement of WML1 capabilities.

(3a) WML extensions elements (for WML1 compatibility):

wml:access wml:anchor wml:card wml:do wml:getvar wml:go wml:noop wml:onevent wml:postfield wml:prev wml:refresh wml:setvar wml:timer

(3b) WML extensions elements (for feature enhancement):

wml:widget

WML Document Structure Modules:

The following elements in the Structure Module are used to specify the structure of a WML2 document:

  • body
  • html
  • wml:card
  • head
  • title

The body Element:

The wml:newcontext attribute specifies whether the browser context is initialised to a well-defined state when the document is loaded. If the wml:newcontext attribute value is "true", the browser MUST reinitialise the browser context upon navigation to this card.

The html Element:

The xmlns:wml attribute refers to the WML namespace for example : http://www.wapforum.org/2001/wml.

The wml:use-xml-fragments attribute is used to specify how a fragment identifier is interpreted by the user agent. For details of use of wml:use-xml-fragments in the go task and the prev task.

The wml:card Element:

The wml:card element specifies a fragment of the document body. Multiple wml:card elements may appear in a single document. Each wml:card element represents an individual presentation and/or interaction with the user.

If the wml:card element's newcontext attribute value is "true", the browser MUST reinitialise the browser context upon navigation to this card.

The head Element:

This element keeps header information of the document like meta element and style sheet etc.

The title Element:

This element is used to put a document title

NOTE: WML developers can use the XHTML document style, that is, body structure, or they can use a collection of cards. When the body structure is used, a document is constructed using a body element. The body element contains the content of the document. When a collection of cards is used, a document is constructed using one or more wml:card elements.

WML2 Tasks

The following tasks are defined in WML2.0. These tasks are very similar to WML1.0

  • The go task
  • The prev task
  • The noop task
  • The refresh task

WML2 Events:

The following event types are defined in WML2:

  • Intrinsic event: An event generated by the user agent and includes the following events similar to WML1.0

    • ontimer
    • onenterforward
    • onenterbackward
    • onpick
  • Extrinsic event: An event sent to the user agent by some external agent. The WML 2 specification does not specify any classes of extrinsic events. One example of a WML extrinsic event class may be WTA events

WML2 Document Type:

WML2 documents are identified by the MIME media type "application/wml+xml". The type "application/xhtml+xml" can be used to identify documents from any of the XHTML-based markup languages, including XHTML Basic.

The DOCTYPE declaration may include the XHTML Basic Formal Public Identifier and may also include the URI of the XHTML Basic DTD as specified below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

Style Sheets with WML2

Style sheets can be used to style WML2 documents. Style information can be associated with a document in 3 ways:

External style sheet:

An external style sheet can be associated with a document using a special XML processing instruction or the link element. The use of the XML processing instruction can also be used.

In the following example, the XML processing instruction is used to associate the external style sheet "mobile.css".

<?xml-stylesheet href="mobile.css" 
                    media="handheld" type="text/css" ?>

In the following example, the link element is used to associate the external style sheet "mystyle.css":

<html>
<head>
<link href="mystyle.css" type="text/css" rel="stylesheet"/>
...
</head>
...
</html>

Internal Style Sheets:

Style information can be located within the document using the style element. This element, like link, must be located in the document header.

The following shows an example of an internal style sheet:

<html>
<head>
<style type="text/css">
p { text-align: center; }
</style>
...
</head>
...
</html>

Inline Style:

You can specify style information for a single element using the style attribute. This is called inline style.

In the following example, inline styling information is applied to a specific paragraph element:

<p style="text-align: center">...</p>

The WML2 Default Style Sheet:

Here is a sample style sheet for WML 2.0:

body, card, div, p, center, hr, h1, h2, h3, h4, h5, h6,
address, blockquote, pre, ol, ul, dl, dt, dd,
form, fieldset, object { display: block }
li      { display: list-item }
head    { display: none }
table   { display: table }
tr      { display: table-row }
td, th  { display: table-cell }
caption { display: table-caption }
th      { font-weight: bolder; text-align: center }
caption { text-align: center }
h1, h2, h3, h4, h5, h6, b, strong { font-weight: bolder }
i, cite, em, var,address { font-style: italic }
pre, code, kbd, pre { white-space: pre }
big     { font-size: larger}
small   { font-size: smaller}
hr      { border: 1px inset }
ol      { list-style-type: decimal }
u       { text-decoration: underline }

The WML2 Elements:

Here is link to a complete list of all the WML2 elements. Most of the elements are available in XHTML specification except few elements starting with WML: These elements are specific to WML.

All the elements having same meaning here what they have in XHTML specification.

WML2 Tags Reference

Summary:

We can conclude that if you know XHTML and WML1.0 then you have nothing to do learn WML2.0

If you are interested for further reading then here you can find complete specification for WAP2.0 and WML2.0



Advertisements
Advertisements