Wml-template

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

WML-テンプレート

<template>は、デッキ内のすべてのカードに<do>および<onevent>要素を適用するために使用されます。 この要素は、デッキ内のすべてのカードのテンプレートを定義し、<template>タグ内のコードがデッキ内の各カードに追加されます。

WMLカードで同じ_name_属性値を持つ別の<do>要素を定義することにより、テンプレートの<do>要素をオーバーライドできます。

<template>要素は、次の属性をサポートしています。

Attribute Value Description
onenterbackward URL Occurs when the user navigates into a card using a "prev" task
onenterforward URL Occurs when the user navigates into a card using a "go" task
ontimer URL Occurs when the "timer" expires
class class data Sets a class name for the element.
id element ID A unique ID for the element.

以下は、<go>要素の使用法を示す例です。

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

<wml>
  <template>
    <do name="main_menu" type="accept" label="Chapters">
      <go href="chapters"/>
    </do>
    <do name="menu_1" type="accept" label="Chapter 1">
      <go href="#chapter1"/>
    </do>
    <do name="menu_2" type="accept" label="Chapter 2">
      <go href="#chapter2"/>
    </do>
    <do name="menu_3" type="accept" label="Chapter 3">
      <go href="#chapter3"/>
    </do>
    <do name="menu_4" type="accept" label="Chapter 4">
      <go href="#chapter4"/>
    </do>
  </template>

  <card id="chapters" title="WML Tutorial">
    <p>
      Select One Chapter:<br/>
      <anchor>
        <go href="#chapter1"/>
        Chapter 1: WML Overview
      </anchor><br/>

      <anchor>
        <go href="#chapter2"/>
        Chapter 2: WML Environment
      </anchor><br/>

      <anchor>
        <go href="#chapter3"/>
        Chapter 3: WML Syntax
      </anchor><br/>

      <anchor>
        <go href="#chapter4"/>
        Chapter 4: WML Elements
      </anchor><br/>
    </p>
  </card>

  <card id="chapter1" title="WML Tutorial Ch1">
    <p>
      <em>Chapter 1: WML Introduction</em><br/>
      ...
    </p>
  </card>

  <card id="chapter2" title="WML Tutorial Ch2">
    <p>
      <em>Chapter 2: WML Environment</em><br/>
      ...
    </p>
  </card>

  <card id="chapter3" title="WML Tutorial Ch3">
    <p>
      <em>Chapter 3: WML Syntax</em><br/>
      ...
    </p>
  </card>

  <card id="chapter4" title="WML Tutorial Ch4">
    <p>
      <em>Chapter 4: WML Elements</em><br/>
      ...
    </p>
  </card>
</wml>

これにより、次のメニューが生成され、すべての章をナビゲートできるようになります。

WAP例11