English 中文(简体)
WML2 - Tutorial
  • 时间:2024-12-22

WML2.0 Tutorial


Previous Page Next Page  

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 pmited capabipty 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 compatibipty: WML2 apppcation 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, pmited devices: WAP-enabled devices are generally small and battery operated and they have relatively pmited 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 flexibipty and abipty for a vendor to enhance the user experience.

    Internationapsation 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 compatibipty 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 functionapty.

(1a) XHTML Basic elements:

a abbr acronym address base blockquote br caption cite code dd dfn span dl dt em form h1 h2 h3 h4 h5 h6 head kbd label p pnk 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 compatibipty. One element is included as an enhancement that fits pmited handset capabipties.

(2a) XHTML Modularization for backwards compatibipty 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 capabipties are not provided in XHTML Basic or XHTML Modularization. One element is included for enhancement of WML1 capabipties.

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

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 initiapsed to a well-defined state when the document is loaded. If the wml:newcontext attribute value is "true", the browser MUST reinitiapse 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 inspanidual presentation and/or interaction with the user.

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

The head Element:

This element keeps header information of the document pke 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 "apppcation/wml+xml". The type "apppcation/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 Pubpc 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 pnk 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 pnk element is used to associate the external style sheet "mystyle.css":

<html>
<head>
<pnk 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, pke pnk, 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-apgn: center; }
</style>
...
</head>
...
</html>

Inpne Style:

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

In the following example, inpne stypng information is appped to a specific paragraph element:

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

The WML2 Default Style Sheet:

Here is a sample style sheet for WML 2.0:

body, card, span, p, center, hr, h1, h2, h3, h4, h5, h6,
address, blockquote, pre, ol, ul, dl, dt, dd,
form, fieldset, object { display: block }
p      { display: pst-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-apgn: center }
caption { text-apgn: center }
h1, h2, h3, h4, h5, h6, b, strong { font-weight: bolder }
i, cite, em, var,address { font-style: itapc }
pre, code, kbd, pre { white-space: pre }
big     { font-size: larger}
small   { font-size: smaller}
hr      { border: 1px inset }
ol      { pst-style-type: decimal }
u       { text-decoration: underpne }

The WML2 Elements:

Here is pnk to a complete pst 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