Wap-wml-syntax

提供:Dev Guides
移動先:案内検索

WAP-WML構文

WAPアーキテクチャの最上層は、WML(WMLおよびWMLスクリプト言語)で構成されるWAE(ワイヤレスアプリケーション環境)で構成されています。

WMLスクリプト言語は、携帯電話などのワイヤレスデバイスを介して送信されるアプリケーションの設計に使用されます。 この言語は、小さな画面と伝送の低帯域幅を処理します。 WMLは、ドキュメントタイプの定義で定義されているXMLのアプリケーションです。

WMLページはデッキと呼ばれます。 それらは、リンクを使用して相互に関連する一連のカードとして構築されます。 携帯電話からWMLページにアクセスすると、ページ内のすべてのカードがWAPサーバーから携帯電話にダウンロードされ、コンテンツが表示されます。

WMLコマンドと構文は、コンテンツを表示し、カード間を移動するために使用されます。 開発者はこれらのコマンドを使用して、変数を宣言し、テキストをフォーマットし、携帯電話で画像を表示できます。

WAPプログラムの構造

WMLプログラムは通常、2つの部分に分割されます-ドキュメントプロローグ*および*ボディ。 次のコードを考慮してください-

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
   <card>

   ...
   </card>
   ...more cards...
</wml>

このテキストの最初の行は、これがXMLドキュメントであり、バージョンが1.0であることを示しています。 2行目では、ドキュメントタイプを選択し、ドキュメントタイプ定義(DTD)のURLを指定します。 このDTDは、WMLの完全なXML定義を提供します。 参照されるDTDはWAP 1.1で定義されていますが、このヘッダーはWMLのバージョンによって変わります。 ツールキットがこのプロローグを自動的に生成するように、ヘッダーを正確にコピーする必要があります。

上記のように、本文は<wml> …​ </wml>タグのペアで囲まれています。 WMLドキュメントの本文は、次の1つ以上で構成することができます-

  • Deck
  • Card
  • 表示するコンテンツ
  • ナビゲーション手順

WMLコマンド

WMLで使用されるコマンドは次のようにまとめられています-

フォーマット

Command Description
<p> Paragraph
<b> Bold
<big> Large
<em> Emphasized
<I> Italicized
<small> Small
<strong> Strongly Emphasized
<u> Underlined
<br> Line Break

画像の挿入

<img src="image-path/image - name" alt="Picture not available"/>

テーブルを使用する

Command Description
<table> Definition of a table
<tr> Defining a row
<td> Defining a column
<Thead> Table header

変数

として宣言-

<setvar name="x" value="xyz"/>

として使用-

$ identifier or
$ (identifier) or
$ (Identifier; conversion)

フォーム

Command Description
<select> Define single or multiple list
<input> Input from user
<option> Defines an option in a selectable list
<fieldset> Defines a set of input fields
<optgroup> Defines an option group in a selectable list

タスク要素

Command Description
<go> Represents the action of switching to a new card
<noop> Says that nothing should be done
<prev> Represents the action of going back to the previous card
<refresh> Refreshes some specified card variables.

イベント

さまざまなイベントは次のとおりです-

Command Description
<do> Defines a do event handler
<onevent> Defines an onevent event handler
<postfield> Defines a postfield event handler
<ontimer> Defines an ontimer event handler
<onenterforward> Defines an onenterforward handler
<onenterbackward> Defines an onenterbackward handler
<onpick> Defines an onpick event handler

サンプルWMLプログラム

次のWMLコードをサーバーのinfo.wmlに保持します。 サーバーがWAP対応の場合、任意のWAPデバイスを使用してこのページにアクセスできます。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<!-- WML prolog.declaration of file type and version>

<wml>
<!-- Declaration of the WML deck>
<card id="info" newcontext="true">
<!-- declaration of a card in deck>
<p align="center"><b>Information Center</b></p>
<!--paragraph declaration to display heading>
<p>
<!--paragraph declaration to display links>
<a href="Movie.wml">1. Movies info.</a>
<a href="Weather.wml">2. Weather Info.</a>
<!--declaration of links for weather and movies>
</p>
</card>
<!-- card end>
</wml>
<!-- program end>