WML2 in Details

Schema for WML2

Because the WML2 specification is based on XML, a Document Type Definition (DTD) is defined for WML2 documents. The DTD is available at the WAP Forum Web site, and any WML2 document should conform to this definition.

The full version of the WML2 DTD containing definitions of all the modules is located at the following URL:

http://www.wapforum.org/dtd/wml20-flat.dtd

For those interested in the previous version, WML 1.3, a DTD is available here:

http://www.wapforum.org/DTD/wml13.dtd

WML2 Tags

The WML2 specification is based on the XHTML Basic 1.0 and Modularization of XHTML W3C Recommendations, and it defines additional WAP-specific extensions and WML1 compatible tags.

Depending on their meaning, the WML tags are grouped into different modules:

  • Structure

  • Text

  • Hypertext

  • Image

  • Tables

  • Lists

  • Forms

  • Metainformation

  • Link

  • Base

  • Object

  • Style Sheet

  • Presentation

  • Events

  • Content and Navigation

Each of the modules defines a set of tags and their attributes. Let's discuss the modules in more detail.

Document Structure

This module defines elements that form the structure of a document. The WML2 specification gives two options in implementing WML documents. It is up to a WML developer to choose either the XHTML style defining the document body within the <body> tag or use a deck/card paradigm with the <wml:card> element. Table 22.1 summarizes elements of the document structure module.

Caution

Do not be confused with the name of the WML2 document root element, which is <html>, not <wml> as it was in WML 1.0 or WML 1.1.


Table 22.1. Tags Defined in the Document Structure Module
Name Attributes Description
html Required:

None

Optional:
												xmlns,
												xmlns:wml,
												version,
												xml:lang,
												wml:onenterforward,
												wml:onenterbackward,
												wml:ontimer,
												wml:use-xml-fragments
											

This element should be the first element of the WML2 document, and its name-space specification (if one is specified) should point to the WML namespace located at the following URL:

http://www.wapforum.org/2001/wml.

An example of the minimal empty WML2 document is demonstrated in Listing 22.1.

Optional tags, such as wml:onenterforward, wml:onenterbackward, and wml:ontimer can be used to specify event-handling behavior, which is discussed later in this chapter.
head Required:

None

Optional:
xml:lang,
												profile
											

The <head></head> tag goes just after the root element of a document and marks the header of the document. The definition of the element in the WML2 specification refers to the W3C HTML4 recommendation.
title Required:

None

Optional:
xml:lang
											

This element should be located within the <head> element. It is used to define the title of the document.
body Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												wml:newcontext,
												wml:onenterforward,
												wml:onenterbackward,
												wml:ontimer
											

If a developer chooses to use the docu-ment paradigm as opposed to deck/card, the document content should be defined within this tag.

Attributes of the body tag allow defining styles for the document, event handling rules, browser behavior on loading the document, and so on.

Only one <body></body> element should appear in the single document.
wml:card Required:

None

Optional:
id,
class,
title,
style,
xml:lang,
wml:newcontext,
wml:onenterforward,
												wml:onenterbackward,
												wml:ontimer
											

This element provides another way of defining a document body. It has pretty much the same set of attributes.

The difference between it and the <body> tag is that a single document can have multiple cards. The <wml:card> can contain an entire body of the document or just a fragment.

Note that it is not allowed to define both the <body> and the <wml:card> within the same document.

Certain requirements should be met in order to make sure that the WML2 document is processed properly. Listing 22.1 demonstrates an example of a minimal WML2 document.

Listing 22.1. Minimal WML2 Document
<!DOCTYPE html PUBLIC"-//WAPFORUM//DTD WML 2.0//EN"
    "http://www.wapforum.org/wml20.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:wml="http://www.wapforum.org/2001/wml">
    <!-- The document goes here -->
</html>

The first line of the document is the standard definition of the XML document type.

Similar to other XML documents, there is a reference to the default namespace, which is XHTML, and to the WML namespace (second line).

The WML document itself should be located within the root element tags <html> and </html>.

Text Module

Most of the elements of the Text Module are defined according to the W3C HTML4 Recommendation. Elements of the text module are responsible for formatting text within the document body. Table 22.2 describes tags that are included in the Text Module.

Table 22.2. Tags Defined in the Text Module
Name Attributes Description
abbr Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

This tag marks an abbreviation. In most cases, it doesn't affect the way a browser will display the text. But for a spellchecker or a Web crawler, it will give enough information to process it according to the rules that apply for abbreviations.
acronym Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

Just as the <abbr> tag defines an abbreviation, the <acronym> tag marks an acronym used in the body of a document.
address Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <address> tag marks a section of a docu ment where the contact information is given.
blockquote Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												cite
											

To mark a long quotation that requires a separate paragraph in the text, the <blockquote> tag is used. The cite attribute can be specified to refer to the source of the quotation by its URI.
br Required:

None

Optional:
id,
												class,
												title,
												style
											

The <br> element forces an agent to break a line of text.
cite Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <cite> element usually references a source of a quotation, but it doesn't allow it to specify a URI of the source, which would have been logical.
code Required:

None

Optional:
												id,
												class,
												title,
												style,
												xml:lang
											

A code example can be formatted by a browser in some special way, so this tag can be used to mark a code fragment in the text of the document.
dfn Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <dfn> element marks the definition of a term.
div Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

In most cases, the <div> tag is used together with style sheets to define the way a part of a document is presented to a user.
em Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <em> tag emphasizes the text enclosed between the opening and closing tags.
h1, h2, h3, h4, h5, h6 Required:

None

Optional:
id,
												class,
												Vtitle,
												style,
												xml:lang
											

These six elements are used to mark different levels of headings within a document. The <h1> is the highest level in the hierarchy, whereas the <h6> is the lowest one.
kbd Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <kbd> element indicates that a user should enter text from the keyboard.
p Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												wml:mode,
												align
											

Paragraphs of text are marked with the <p> element.

The <p> tags cannot be nested into one another.

The styling attributes align and wml:mode are deprecated in WML2, and the developers should use the WCSS properties text-align and white-space instead.
pre Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												xml:space
											

The <pre> tag indicates that the text within the element is preformatted and therefore should be presented as it appears in the text of a document.
q Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												cite
											

Another way to mark a quotation is using the <q> element, which is treated almost like the <blockquote>, but is not presented in a separate paragraph. Usually this tag marks short inline quotations.
samp Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

Documents can include samples of program output, and the <samp> element can be used in conjunction with style sheets to format them properly.
span Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <span> tag marks a section of a document just like the <div> does: The only difference is that the <span> is an inline section.
strong Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <strong> element emphasizes the text enclosed within it. The emphasis is stronger than with the <em> tag.
var Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

This tag marks a variable. Usually it does not make any sense for a browser, but it can be used to give a hint to a spellchecker, a search engine, and so on.

Hypertext

The Hypertext module defines only one tag, the anchor element <a>, which is used to specify a hypertext anchor within the body of a WML document.

An anchor can associate a text fragment with a link to another site, such as in this example:

More on foo: <a href="wap://www.foo.com/bar.wml">bar</a> 

The preceding code associates the word bar with a URL pointing to a WAP site wap://www.foo.com/bar.wml.

Or it can be used by WML developers to associate a label within the document that can be accessed from another location within or outside the document:

<a id = "foo" name = "foo"> 
Here you can find a complete collection of links to sites about foo
</a>

Assuming that this fragment of code is a part of the document located at the URL wap://www.foo.com/bar.wml, we can navigate directly to a part of the document starting with this anchor using the following URL: wap://www.foo.com/bar.wml#foo.

Note

The preceding example uses both the id and name attributes. The name attribute is used for compatibility, but it is preferred to specify the id attribute in XHTML and hence, in WML. Refer to Chapter 21, “The Future of the Web: XHTML,” for more details on this.


Table 22.3 summarizes attributes of the anchor element.

Table 22.3. Tags Defined in the Hypertext Module
Name Attributes Description
a Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												href,
												charset,
												type,
												hreflang,
												rel,
												rev,
												accesskey,
												tabindex
											

A hypertext anchor within the body of a WML document

In most cases, it is used in conjunction with href or name attributes.

The href attribute provides a link to another document through its URI.

The name attribute puts an anchor into the text so that other sections of the document or other documents can refer to the section starting with this anchor element.

Other attributes can be used to associate some additional information with the anchor, such as the language of the referred document.

Image

The <img> tag, defined in the Image module is used whenever it is needed to insert an image into a WML document. Its attributes allow specifying the dimensions of the image, its source, description, and so on.

The attributes of the <img> element are listed in Table 22.4.

Table 22.4. Tags Defined in the Image Module
Name Attributes Description
img Required:
src,
												alt
											

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												longdesc,
												height,
												width,
												wml:localsrc,
												wml:type,
												vspace,
												hspace,
												align
											

The <img> tag marks an image embedded within a document.

The src attribute is a URI of the image source.

The alt attribute defines an alternative text that briefly describes the image. This text can be used by a browser when it cannot display the image.

The wml:localsrc attribute specifies the alternative local source that the image should be loaded from. The src attribute is ignored if the image can be loaded from the local source.

The wml:type attribute can be used to tell the browser about the media type of the image.Other attributes can be used to pre-format the image; that is, force its size to specified dimensions, define its alignment and spacing, and so on.

Tables

The Tables module describes WML2 elements responsible for formatting and displaying tables. A typical table consists of a header, caption, rows, and columns. The formatting options for tables could be alignment, spacing, and so on, and can be applied to any element of the table.

Tables or separate cells can be associated with style sheets, thus making it possible to create unique representations of tables. Table 22.5 summarizes the elements of the WML2 Tables module and their attributes.

Table 22.5. Tags Defined in the Tables Module
Name Attributes Description
caption Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

This element should be specified immediately after the opening <table> tag. It is used bybrowsers to provide a user with a brief description of the table. The <caption> element is optional, butsometimes it is a useful hint, which can save a user time.
table Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												summary,
												wml:columns,
												wml:align
											

The <table> tag defines a table in the body of a WML document.

To make tables more accessible for disabled users, an attribute summary is often used by special browsers that render the information to speech engines or other special accessibility tools.

It is usually helpful to specify the number of columns in the table using the wml:columns attribute. This will give the browser a hint about the table so that it can start displaying the table before the closing </table> tag gets to the parser.

The wml:align attribute is deprecated, and it is not recommended to use it. The WML specification encourages using WCSS style properties.
tr Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												align,
												valign
											

The <tr> element describes a row in a table. This element encapsulates table cells <td> and cell headers <th>.
td Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												abbr,
												axis,
												headers,
												scope,
												rowspan,
												colspan,
												align,
												valign
											

The table data is located within cells described with the <td> element.

The specification allows developers to categorize table cells using the axis attribute. A browser then can display just a part of the table based on the category chosen by a user.

The headers and scope attributes establish associations between data cells and headers describing data in the cells.

The rowspan and colspan attributes define the number of rows and columns, respectfully, spanned by the data cell.

The data in the cell can be aligned horizontally and vertically using the align and valign attributes.

Just like most of the elements in WML2, the td can be associated with style sheets.
th Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												abbr,
												axis,
												headers,
												scope,
												rowspan,
												colspan,
												align,
												valign
											

The <th> element is used to define column headers for tables. The attributes are used with this element the same way as with the <td> element.

Listing 22.2 illustrates the use of the Tables Module tags to define a simple table.

Listing 22.2. Example of the Table Definition
<table summary="This table describes our services and latest prices.">
    <caption>Pricelist</caption>
    <tr>
        <th>Ref. number</th>
        <th>Title</th>
        <th>Summary</th>
        <th>Availability</th>
        <th>Price</th>
    </tr>
    <tr>
        <td>0001</td>
        <td>Pizzas on-line</td>
        <td>Choose from more then twenty varieties of pizza now!</td>
        <td>Available</td>
        <td>7.50 EUR</td>
    </tr>
    <tr>
        <td>0002</td>
        <td>Holiday offers</td>
        <td>Think about your holiday now and book it on-line!</td>
        <td>Limited</td>
        <td>From 300 EUR</td>
    </tr>
</table>

The table described in this example consists of the caption, column headers, two rows, and five columns. The table summary provides additional information about the table that can be useful for disabled users accessing the WML page with a non-visual device.

Lists

WML2 provides the developers with a number of special tags that can be used to organize information into lists of items. Three types of lists are defined in WML:

  • Ordered

  • Unordered

  • Definition

For each type of lists, special tags are defined. Table 22.6 describes each of them in alphabetical order.

Table 22.6. Tags Defined in the Lists Module
Name Attributes Description
dt Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <dt> tag marks the term in the definition list.

It is used in conjunction with <dd> and <dl> tags.

It is assumed that the definition of the term marked with the <dt> tag goes next to it and is enclosed into one or multiple <dd> elements.

One term can be associated with multiple definitions, or multiple terms can be associated with one definition.
dd Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The definition of the term is enclosed within the <dd> tag.
dl Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <dl> tag marks the definition list. The elements of the list are marked with the <dd> and <dt> tags. This type of list can be used for more than definitions. It can also be used for listing phone numbers, marking dialogues, and so on.
ol Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												start
											

The <ol> tag marks an ordered list of information items. Ordered list items are numbered by user agents.
ul Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <ul> tag marks unordered list of items. User agents usually display unordered lists as bulleted lists.
li Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												value
											

The <li> tag marks a list item. It can be used in conjunction with ordered and unordered lists, but not with definition lists.

Listing 22.3. Example of the Definition List
<dl>
    <dt xml:lang="en-US">Theater
    <dt xml:lang="en-UK">Theatre
    <dd xml:lang="en">A building or an outdoor area where plays and
        similar types of entertainment are performed.
    <dd xml:lang="en-US">Same as cinema
    <dd xml:lang="en">Plays considered as entertainment
    <dd>The work of writing, producing and acting in plays.
    <dd xml:lang="en-UK">Same as operating theatre.
    <dd xml:lang="en">The place in which the war or fighting takes place.

    <dt>Cinema
    <dd xml:lang="en-UK">A building in which films or movies are shown.
</dl>

Listing 22.3 illustrates the use of definition list tags to define the meaning of words theatre, theater, and cinema. (Descriptions of these terms have been taken from the Oxford Advanced Learner's Dictionary.)

Forms

The interactive content of WML pages is usually based on forms, which allow end users to submit information required by a WAP application. The Forms module describes the tags and attributes that make possible the interaction between users and servers. These tags and their attributes are listed in Table 22.7.

Table 22.7. Tags Defined in the Forms Module
Name Attributes Description
form Required:
action
											

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												method,
												enctype
											

The <form> tag marks the beginning of the form. This element is a container for all the form's controls and text. The important attributes of this element are method, which defines how the data submitted by the user will be transmitted to the server and action, which is a URI of the agent that should receive and process the data submitted by the user.
input Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												type,
												name,
												value,
												checked,
												size,
												maxlength,
												src,
												tabindex,
												accesskey,
												wml:format,
												wml:emptyok,
												wml:name
											

The <input> tag defines a control that expects a user to enter some information.

There are quite a lot of pre-defined control types, and the behavior of the control depends on its type.

For example, if the type is password, a control is a single-line text box, which hides the text entered by a user with asterisks or some other symbol.

Most of the attributes of the <input> element are defined according to the XHTML specification and allow initializing the value and initial state of the control, its dimensions, format, and so on.

The WML specific attributes are wml:name, which specifies the name of the control and has higher priority than the XHTML name attribute.

wml:format and wml:emptyok, which describe the input mask for the control value.

Input controls can be associated with style sheets.
select Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												name,
												size,
												multiple,
												tabindex,
												wml:iname,
												wml:value,
												wml:ivalue,
												wml:name
											

The <select> is another type of control, and it represents a menu.

The choices of the menu are defined and organized using the <option> and <optgroup> tags.

The WML specific attributes of this element are The wml:name and wml:value, which specify the name and value of the control variable.

The wml:iname and wml:ivalue, which set the control's index variable.
option Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												selected,
												value,
												wml:onpick
											

The <option> tag marks a choice of the menu.

The wml:onpick attribute allows associating an event handler with the control, which is executed when the option is picked.

All other attributes are the XHTML legacy attributes.
label Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												for,
												accesskey
											

The <label> element associates a label with a control. The value of the for attribute should be the same as the value of the id attribute of the control. Only one label can be associated with a control.
textarea Required:
rows,
												cols
											

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												name,
												tabindex,
												accesskey,
												wml:format,
												wml:emptyok,
												wml:name
											

The <textarea> tag defines a multiline text input box.

It is required to specify the dimensions of the area using the rows and cols attributes.

The WML specific attributes of the element are wml:name, which specifies the name of the control and has higher priority than the XHTML name attribute.

wml:format and wml:emptyok, which describe the input mask for the control value.
optgroup Required:
label
											

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <optgroup> element allows authors to create groups of options within the menu. The element is used in conjunction with the <select> and <option> elements.
fieldset Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

It is often necessary to group controls to make the form more intuitive to use. The <fieldset> tag can be used to group form controls that logically relate one to another.

Metainformation

WML developers use metainformation to specify “data about data”—properties describing a document, its contents, authors, keywords, and so on.

Metadata is specified as name = value pairs using the meta keyword described in Table 22.8.

Table 22.8. Tags Defined in the Metainformation Module
Name Attributes Description
meta Required:
content
											

Optional:
xml:lang,
												http-equiv,
												name,
												scheme,
												wml:forua
											

The <meta> element defines a property of a document.

The name attribute defines the property name.

The content attribute defines its value.

The http-equiv attribute can be used instead of name when it is necessary for this property to be a part of the WAP header.

The wml:forua is deprecated. If used, it tells the user agent or intermediate agent whether to deliver the metatag (true) or ignore it (false).

Link

The Links module defines just one tag described in Table 22.9, which can be used to establish relationships of the document with other resources on the Web.

Table 22.9. Tags defined in the Link Module
Name Attributes Description
link Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												charset,
												href,
												hreflang,
												type,
												rel,
												rev,
												media
											

The <link> element describes a link to another document that can be used by a user agent in some special way—for example, displayed in the menu or in a toolbar. The element can only appear within the <head> section, and thus is not the same as the anchor element <a>.

Base

The Base module and its only element, <base>, describe the base URI of the document, allowing user agents to resolve relative URIs used in the document properly. The element is described in Table 22.10.

Table 22.10. Tags Defined in the Base Module
Name Attributes Description
base Required:
href
											

Optional:

None
Specifies the base URI to be used with the document.

Object

The Object Module deals with elements that are used to handle embedded data types not supported by browsers internally, but that can be understood by external programs. These elements and their attributes are described in Table 22.11.

Table 22.11. Tags Defined in the Object Module
Name Attributes Description
object Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												declare,
												classid,
												codebase,
												data,
												type,
												codetype,
												archive,
												standby,
												height,
												width,
												name,
												tabindex
											

The <object> tag defines an embedded object. For example, if the mobile device supports Java, it can be a java applet.

Most of the attributes describe the object in different ways.

The classid attribute specifies a URL from where the code can be downloaded.

The data attribute points to the location of the object data.
param Required:
name
											

Optional:
id,
												value,
												valuetype,
												type
											

To initialize objects with runtime data, the <param> tag is used.

Each <param> tag contains a name=value pair.

Note that the use of the closing tag is forbidden.

Stylesheet

The only tag of the Stylesheet module is used to define internal style sheets within the WML documents. The tag is described in Table 22.12.

Table 22.12. Tags Defined in the Stylesheet Module
Name Attributes Description
style Required:
type
											

Optional:
title,
												xml:lang,
												media,
												xml:space
											

The <style> tag can be used within the <head> section of the WML document, and it defines an internal style sheet rule.

The following example illustrates the use of the <style> tag. The result of this internal style definition is that all the anchor elements in the document will be displayed using small letters.

<head> 
    <style>
        a {font-variant:small-caps}
    </style>
</head>

Presentation

The Presentation module defines tags that change the look of the text. Most of them are deprecated. The developers are advised to use WCSS styles instead. The tags are listed in Table 22.13.

Table 22.13. Tags Defined in the Presentation Module
Name Attributes Description
b Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The text within the opening <b> and closing </b> tags will be displayed as bold.

Note: The tag is deprecated.

i Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The text within the opening <i> and closing </i> tags will be displayed in italics.

Note: The tag is deprecated.

small Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The text within the opening <small> and closing </small> tags will be displayed using small font.

Note: The tag is deprecated.

big Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The text within the opening <big> and closing </big> tags will be displayed using big font.

Note: The tag is deprecated.

u Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The text within the opening <u> and closing </u> tags will be underlined.

Note: The tag is deprecated.

hr Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang
											

The <hr> tag adds a horizontal rule to the document.

Events

Before proceeding to the discussion of the elements defined in the Events, Context, and Navigation modules, we need to take a quick look at the event handling mechanisms of WML.

Many of the XHTML and WML elements allow events to be associated with different kinds of user actions. It is also possible that an event might come from some external source. These events should also be treated properly by documents.

There are two kinds of events in WML:

  • Intrinsic events, generated by the user agent.

  • Extrinsic events, originated from an external source.

The events defined in the specification are all intrinsic events—in particular they are timer, enterforward, enterbackward, and pick. Different tasks, which are navigational directives, can be associated with events. The tasks are go, refresh, noop, and prev.

The WML allows associating special tasks with different kinds of events, such as expiration of timer, and so on. One of the ways of doing this is to use the wml:onevent tag described in Table 22.14.

Table 22.14. Tags Defined in the Events Module
Name Attributes Description
wml:onevent Required:
type
											

Optional:
id,
												class,
												title,
												style
											

The <wml:onevent> tag binds an event with a task The required attribute type supplies the name of the event type.

Context and Navigation Module

The use of the wml:onevent tag is not the only way of dealing with events in WML2. A special set of WML-specific tags, listed in Table 22.14, takes care of the user agent context and behavior and allows associating different tasks with different kinds of events.

The user agent context usually comprises two major components:

  • Navigation history— A stack of resources the user navigated to prior to getting to the current resource

  • WML variables— a set of name/value pairs, which can be defined by documents or referenced by documents at runtime.

These tags defined in the Context and Navigation module are compatible with WML 1.

Table 22.15 briefly describes Context and Navigation module tags.

Table 22.15. Tags Defined in the Presentation Module
Name Attributes Description
wml:anchor Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												accesskey
											

The wml:anchor element defines a hyperlink just like the a element does—with the exception that the destination anchor is a task, such as wml:go. The specified task is executed by the user agent whenever a user clicks the element.

The id, class, title, style and xml:lang attributes are standard attributes that can be found in almost any XHTML tag.

The accesskey attribute specifies an access key to the element, but the WML 2 specification recommends using the WCSS wap-accesskey property instead of this attribute.
wml:access Required:

None

Optional:
id,
												class,
												title,
												style,
												domain,
												path
											

The wml:access tag defines the access rules that apply to the document. Only one wml:access element can be present in the document. The domain and path attributes are used to define the locations of other documents that are allowed to access this document. If the attributes are present, there will be no access to the document from any locations other than the one specified.
wml:do Required:

None

Optional:
id,
												class,
												title,
												style,
												xml:lang,
												role
											

The wml:do tag associates a task, which will be executed when a user activates the element. The actual task is defined by the role attribute, which can have predefined values such as accept or reset.
wml:go Required:
href
											

Optional:
id,
												class,
												title,
												style,
												sendreferer,
												method,
												enctype,
												accept-charset,
												cache-control,
												type
											

The wml:go task forces the user agent to navigate to a URL specified in the href attribute.

The sendreferer attribute tells the browser whether to send a URI of the referring document to the server.

The method attribute is an HTTP request method, such as GET, PUT, or POST.
wml:noop Required:

None

Optional:
id,
												class,
												title,
												style
											

This element is an empty task: “do nothing.”
wml:prev Required:

None

Optional:
id,
												class,
												title,
												style
											

This element specifies a task of navigating to the previous URI in the history list.
wml:refresh Required:

None

Optional:
id,
												class,
												title,
												style
											

The task declared by means of this element refreshes the browser context.
wml:postfield Required:
name,
												value
											

Optional:
id,
												class,
												title,
												style
											

When a URI is requested, this element can be used to set parameters that should be attached to the server request.
wml:setvar Required:
name,
												value
											

Optional:
id,
												class,
												title,
												style
											

Sets the variable in the current user agent context.
wml:getvar Required:
name
											

Optional:
id,
												class,
												title,
												style,
												conversion
											

Retrieves the value of the variable defined in the current user agent context. The value is substituted to the text of the document.
wml:timer Required:
value
											

Optional:
id,
												name,
												class,
												title,
												style
											

The wml:timer element declares a timer and initializes it with the value specified in the value attribute. The timer can be used, for example, to measure inactivity intervals and perform some actions if a user is idle for too long.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.234