当前位置: 首页 > 网络学院 > XML相关教程 > WAP > WML 实例

WAP
WAP 介绍
WAP 基础知识
WML 格式化
WML 链接
WML Input
WML 任务
WML 计时器
WML 变量
WML 实例
Validate WML
WML 参考
WML 字符实体
WML DTD

WAP 中的 WML 实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 775 ::
收藏到网摘: n/a

A WML deck with two cards - one for user input and one for displaying the result - can be set up, as demonstrated in this example:
有两张“card”的WML deck——一张用于用户输入,一张用于显示结果——,可以进行设置,像下面例子中示范的那样:

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Tutorial">
<do type="accept" label="Answer"> <go href="#card2"/>
</do>
<p>
<select name="name"> <option value="HTML">HTML Tutorial</option> <option value="XML">XML Tutorial</option> <option value="WAP">WAP Tutorial</option>
</select>
</p>
</card>
<card id="card2" title="Answer">
<p>
You selected: $(name)
</p>
</card>
</wml>

The first card might look like this in your mobile phone display:
手机显示的第一张“card“可能会像这样:

----- Tutorial ---------- HTML Tutorial  XML Tutorial  WAP Tutorial 
Answer

The second card might look like this:
第二张“card”可能会像这样:

----- Answer ---------- You Selected: HTML


Example Explained
例子解释

The Prolog
序言

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

The first lines in the WML document are called the prolog. The prolog defines that this is an XML document, it then defines the XML version, and the DTD to be referenced.
WML文档中的首几行叫做序言。序言指出了这是一份XML文档,然后定义了XML版本,和供参考的DTD文件

The Deck

<wml> ..... </wml>

The deck is the WML document itself. It is embedded within <wml> tags
Deck是WML文档本身。它被植入在<wml>标签里 。

The Cards

<card> ..... </card>

Cards are always displayed one at the time. This WML deck contains two cards - one for user input and one for displaying the result.
“card”总是被显示一张。这里的WML deck包含两张card——一张用于用户输入一张用于显示结果。

The <do> element
<do>元素

<do> ... </do>

The first card has a <do> element that defines an event to be triggered. The type="accept" attribute of the <do> element causes the label="Answer" to be displayed in the lower left corner of the display.
第一张card有个定义触发事件的<do>元素 。<do>元素的type="accept"属性会使label="Answer"显示在显示内容下方的左角。

The Event

The <go> element triggers when the user clicks the <do> label. The href="#card2" attribute of the <go> element causes card2 to be displayed on the screen.
当用户点击<do>标签时,<go>元素会被触发。<go>元素的href="#card2"属性会让card2显示在屏幕上。

The Variable

Card2 displays the $(name) variable from card1, because variables are valid across cards.
card2显示了card1的$(name)变量,因为变量在不同card里仍是有效的。

评论 (0) All

登陆 | 还没注册?