1 
CSIT600b: XML Programming 
WML 
Dickson K.W. Chiu 
PhD, SMIEEE 
Thanks to Prof. S.C. Cheung (HKUST)
Wireless Application Protocol (WAP) 
 Leading standard for information services on wireless 
terminals like digital mobile phones. 
 Based on Internet standards (HTML, XML and TCP/IP). 
Dickson Chiu-2004 CSIT600b 03-2 
 Consists of 
 WML language specification 
 a WMLScript specification 
 a light JavaScript language 
 not embedded in the WML pages 
 WML pages only contains references to script URLs 
 need to be compiled into byte code on a server 
 a Wireless Telephony Application Interface (WTAI) specification 
 Published by the WAP Forum 
 founded in 1997 by Ericsson, Motorola, Nokia, and Unwired Planet 
 Forum members now represent over 90% of the global handset 
market, as well as leading infrastructure providers, software 
developers and other organizations.
Wireless Markup Language (WML) 
 WML based on XML and HTML. 
 WML documents are divided into a set 
of cards, each representing one unit of 
interaction between the user and the 
user agent. 
 Instructions embedded within cards 
may invoke services on origin servers. 
 Several cards are grouped into a deck, 
the basic WML unit, that origin server 
can send to a user agent. 
Dickson Chiu-2004 CSIT600b 03-3 
 See: 
http://www.w3schools.com/wap/default 
.asp 
Welcome 
to 
MTM515!! 
Emulator - http://ttemulator.com/
WML – One Card 
Text is specified inside p element. 
A card can have none, one or several p elements. 
Element br indicates start of a new line. 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
Dickson Chiu-2004 CSIT600b 03-4 
<wml> 
<!-- THIS IS THE FIRST CARD IN THE DECK --> 
<card id="start" title=“S.C. Cheung WAPSITE"> 
<p> 
Welcome to MTMI515!! 
</p> 
</card> 
</wml>
WML – Font Style 
Text emphasis elements em, strong, b, i, u, big, 
small - meanings equivalent to HTML counterparts. 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml> 
<!-- THIS IS THE FIRST CARD IN THE DECK --> 
<card id="start" title="S.C. Cheung WAPSITE"> 
<p> 
<b>This is bold</b><br/> 
<i>This is Italic</i><br/> 
<u>This is Underline</u><br/> 
<big>This is Big text</big><br/> 
<small>Small Text</small><br/> 
<strong>This Is STRONG</strong> 
</p> 
</card> 
</wml> 
Dickson Chiu-2004 CSIT600b 03-5
WML – Two Cards 
Attributes id in card elements serve as 
anchor for intercard links. 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml> 
<!-- THIS IS THE FIRST CARD IN THE DECK --> 
<card id="start" title="S.C. Cheung WAPSITE"> 
<p>Next tutorial.<br/> 
<a href="#tutorial">Continue Tutorial</a> 
</p> 
</card> 
<!-- THIS IS THE SECOND CARD IN THE DECK --> 
<card id="tutorial" title="S.C. Cheung WAPSITE"> 
<p align="center">Welcome To part 2<br/> 
Here the tutorial continues 
</p> 
</card> 
</wml> 
Dickson Chiu-2004 CSIT600b 03-6
WML – Three Cards 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
Dickson Chiu-2004 CSIT600b 03-7 
<wml> 
<!-- THIS IS THE FIRST CARD IN THE DECK --> 
<card id="start" title="S.C. Cheung WAPSITE"> 
<p align="center"> 
<big><u>Tutorials</u></big> 
</p> 
<p align="left"><small>Want to see a <a 
href="#joke">Joke</a>.</small></p> 
<p align="left"><small>Are how about a <a 
href="#pic">Picture</a>.</small></p> 
</card>
WML – Three Cards 
<!-- THIS IS THE SECOND CARD IN THE DECK --> 
<card id="joke" title="S.C. Cheung WAPSITE"> 
<p align="center">Joke's</p> 
<p><small>1. What do you get if you cross an owl with a skunk?<br/> 
A. bird that smells but doesn't give a hoot !!!!!!!!</small></p> 
<p><small>2.Why did the rooster cross the road?<br/> 
A. To prove he wasn't chicken !!</small></p> 
</card> 
<!-- THIS IS THE THIRD CARD IN THE DECK --> 
<card id="pic" title="S.C. Cheung WAPSITE"> 
<p align="center"><b>Picture</b></p> 
<p align="center"><img src="child3.wbmp" alt=" HI"/></p> 
Dickson Chiu-2004 CSIT600b 03-8 
</card> 
</wml>
Dickson Chiu-2004 CSIT600b 03-9 
WML - Table 
<card title="Table"> 
<p> 
<table columns="3"> 
<tr> 
<td>Cell 1</td> 
<td>Cell 2</td> 
<td>Cell 3</td> 
</tr> 
</table> 
</p> 
</card> 
</wml>
WML – Anchor 
Always has a task ("go", "prev", or "refresh") specified. 
The task defines what to do when the user selects the link. 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml> 
<card title="Anchor Tag"> 
<p> 
<anchor>Next page 
<go href="demo_wap_text.wml"/> 
</anchor> 
</p> 
</card> 
</wml> 
Dickson Chiu-2004 CSIT600b 03-10
Dickson Chiu-2004 CSIT600b 03-11 
WML - Input 
<?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="input1" title="Info"> 
<p> 
A: <input name="Name" size="15"/> 
B: <input name="Age" size="15" format="*N"/> 
C: <input name="Sex" size="15"/> 
</p> 
</card> 
</wml>
Dickson Chiu-2004 CSIT600b 03-12 
WML - Select 
<?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="Sections"> 
<p> 
<select name="name"> 
<option value="HTML">HTML Section</option> 
<option value="XML">XML Section</option> 
<option value="WAP">WAP Section</option> 
</select> 
</p> 
</card> 
</wml> 
<select multiple="true">
WML - Refresh 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
Dickson Chiu-2004 CSIT600b 03-13 
<wml> 
<card> 
<p> 
<anchor> 
Refresh This Page 
<go href="#refresh"/> 
</anchor> 
</p> 
</card> 
</wml> 
<card id="refresh" title="S.C. Cheung WAPSITE"> 
<refresh/> 
</card>
Dickson Chiu-2004 CSIT600b 03-14 
WML - Timer 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml> 
<card ontimer="2.wml"> 
<timer value="10"/> 
<p>Some Message</p> 
</card> 
</wml>
WML - Variables 
 Specify a variable with the Setvar command 
 <setvar name="i" value="500"/> 
 Specify a variable through an input element (like 
input, select, option, etc.) 
<card id="card1"> 
<select name=“opt"> 
<option value="HTML">HTML Tutorial</option> 
<option value="XML">XML Tutorial</option> 
</select> 
</card> 
 To use the variable we created in the example above: 
<card id="card2"> 
<p>You selected: $(opt)</p> 
</card> 
Dickson Chiu-2004 CSIT600b 03-15
WML - Posting to the Server 
<!-- From: http://www.topxml.com/wap/articles/wml_jsp/default.asp --> 
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" 
"http://www.phone.com/dtd/wml11.dtd"> 
Dickson Chiu-2004 CSIT600b 03-16 
<wml> 
<card id="start" title="Weather"> 
<do type="accept" label="Go!" > 
<go href="weather.jsp"><!-- submitted to a JSP --> 
<postfield name="query" value="$query" /> 
<postfield name="QP1" value="$QP1" /> 
<postfield name="target" value="wml-$(query)" /> 
</go> 
</do> 
<p align="center">Weather Page</p> 
<p> 
Zip? <input name="QP1" format="*N" maxlength="10" value="" /><br /> 
Query? <select name="query"> 
<option value="TimeTemp" > time &amp; temp </option> 
<option value="AllTable" > all fields </option> 
<option value="AllText" > all fields format</option> 
</select> 
</p> 
</card> 
</wml>
Generating WML with XSLT 
<!-- Available: http://kwchiu.dyndns.org:7999/xslt3.xsl --> 
<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 
<wml> 
<card> 
<table> 
<?xml version="1.0" encoding="UTF-8"?> 
<wml> <card> 
<table> 
<tr><td>CHEUNG KONG</td> 
<td>64.00</td></tr> 
</table> 
… 
</card></wml> 
Dickson Chiu-2004 CSIT600b 03-17 
<xsl:for-each 
select="/hsiComponents/component"> 
<tr> 
<td><xsl:value-of select="name"/></td> 
<td><xsl:value-of select="lastTrade"/></td> 
</tr> 
</xsl:for-each> 
</table> 
</card> 
</wml> 
</xsl:template> 
</xsl:stylesheet> 
<?xml version="1.0" encoding="UTF-8"?> 
<hsiComponents> 
<component> 
<name>CHEUNG KONG</name> 
<lastTrade>64.00</lastTrade> 
</component> 
... 
</hsiComponents>
Dickson Chiu-2004 CSIT600b 03-18 
WAP Emulator 
 http://www.gelon.net/ 
 Paste URL to WAP emulator: 
 http://kwchiu.dyndns.org:7999/html2dom/result?s 
ourceURL=http%3A%2F%2Ffinance.yahoo.com% 
2Fq%2Fcp%3Fs%3D%5EHSI&xslt1URL=http%3A 
%2F%2Fkwchiu.dyndns.org%3A7999%2Fxslt1.xsl 
&xslt2URL=http%3A%2F%2Fkwchiu.dyndns.org 
%3A7999%2Fxslt3.xsl&submit=convert 
 More sophisticated development: 
 http://www.forum.nokia.com/main/0,6566,034- 
521,00.html

XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE

  • 1.
    1 CSIT600b: XMLProgramming WML Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. S.C. Cheung (HKUST)
  • 2.
    Wireless Application Protocol(WAP)  Leading standard for information services on wireless terminals like digital mobile phones.  Based on Internet standards (HTML, XML and TCP/IP). Dickson Chiu-2004 CSIT600b 03-2  Consists of  WML language specification  a WMLScript specification  a light JavaScript language  not embedded in the WML pages  WML pages only contains references to script URLs  need to be compiled into byte code on a server  a Wireless Telephony Application Interface (WTAI) specification  Published by the WAP Forum  founded in 1997 by Ericsson, Motorola, Nokia, and Unwired Planet  Forum members now represent over 90% of the global handset market, as well as leading infrastructure providers, software developers and other organizations.
  • 3.
    Wireless Markup Language(WML)  WML based on XML and HTML.  WML documents are divided into a set of cards, each representing one unit of interaction between the user and the user agent.  Instructions embedded within cards may invoke services on origin servers.  Several cards are grouped into a deck, the basic WML unit, that origin server can send to a user agent. Dickson Chiu-2004 CSIT600b 03-3  See: http://www.w3schools.com/wap/default .asp Welcome to MTM515!! Emulator - http://ttemulator.com/
  • 4.
    WML – OneCard Text is specified inside p element. A card can have none, one or several p elements. Element br indicates start of a new line. <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> Dickson Chiu-2004 CSIT600b 03-4 <wml> <!-- THIS IS THE FIRST CARD IN THE DECK --> <card id="start" title=“S.C. Cheung WAPSITE"> <p> Welcome to MTMI515!! </p> </card> </wml>
  • 5.
    WML – FontStyle Text emphasis elements em, strong, b, i, u, big, small - meanings equivalent to HTML counterparts. <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <!-- THIS IS THE FIRST CARD IN THE DECK --> <card id="start" title="S.C. Cheung WAPSITE"> <p> <b>This is bold</b><br/> <i>This is Italic</i><br/> <u>This is Underline</u><br/> <big>This is Big text</big><br/> <small>Small Text</small><br/> <strong>This Is STRONG</strong> </p> </card> </wml> Dickson Chiu-2004 CSIT600b 03-5
  • 6.
    WML – TwoCards Attributes id in card elements serve as anchor for intercard links. <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <!-- THIS IS THE FIRST CARD IN THE DECK --> <card id="start" title="S.C. Cheung WAPSITE"> <p>Next tutorial.<br/> <a href="#tutorial">Continue Tutorial</a> </p> </card> <!-- THIS IS THE SECOND CARD IN THE DECK --> <card id="tutorial" title="S.C. Cheung WAPSITE"> <p align="center">Welcome To part 2<br/> Here the tutorial continues </p> </card> </wml> Dickson Chiu-2004 CSIT600b 03-6
  • 7.
    WML – ThreeCards <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> Dickson Chiu-2004 CSIT600b 03-7 <wml> <!-- THIS IS THE FIRST CARD IN THE DECK --> <card id="start" title="S.C. Cheung WAPSITE"> <p align="center"> <big><u>Tutorials</u></big> </p> <p align="left"><small>Want to see a <a href="#joke">Joke</a>.</small></p> <p align="left"><small>Are how about a <a href="#pic">Picture</a>.</small></p> </card>
  • 8.
    WML – ThreeCards <!-- THIS IS THE SECOND CARD IN THE DECK --> <card id="joke" title="S.C. Cheung WAPSITE"> <p align="center">Joke's</p> <p><small>1. What do you get if you cross an owl with a skunk?<br/> A. bird that smells but doesn't give a hoot !!!!!!!!</small></p> <p><small>2.Why did the rooster cross the road?<br/> A. To prove he wasn't chicken !!</small></p> </card> <!-- THIS IS THE THIRD CARD IN THE DECK --> <card id="pic" title="S.C. Cheung WAPSITE"> <p align="center"><b>Picture</b></p> <p align="center"><img src="child3.wbmp" alt=" HI"/></p> Dickson Chiu-2004 CSIT600b 03-8 </card> </wml>
  • 9.
    Dickson Chiu-2004 CSIT600b03-9 WML - Table <card title="Table"> <p> <table columns="3"> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> </table> </p> </card> </wml>
  • 10.
    WML – Anchor Always has a task ("go", "prev", or "refresh") specified. The task defines what to do when the user selects the link. <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card title="Anchor Tag"> <p> <anchor>Next page <go href="demo_wap_text.wml"/> </anchor> </p> </card> </wml> Dickson Chiu-2004 CSIT600b 03-10
  • 11.
    Dickson Chiu-2004 CSIT600b03-11 WML - Input <?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="input1" title="Info"> <p> A: <input name="Name" size="15"/> B: <input name="Age" size="15" format="*N"/> C: <input name="Sex" size="15"/> </p> </card> </wml>
  • 12.
    Dickson Chiu-2004 CSIT600b03-12 WML - Select <?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="Sections"> <p> <select name="name"> <option value="HTML">HTML Section</option> <option value="XML">XML Section</option> <option value="WAP">WAP Section</option> </select> </p> </card> </wml> <select multiple="true">
  • 13.
    WML - Refresh <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> Dickson Chiu-2004 CSIT600b 03-13 <wml> <card> <p> <anchor> Refresh This Page <go href="#refresh"/> </anchor> </p> </card> </wml> <card id="refresh" title="S.C. Cheung WAPSITE"> <refresh/> </card>
  • 14.
    Dickson Chiu-2004 CSIT600b03-14 WML - Timer <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card ontimer="2.wml"> <timer value="10"/> <p>Some Message</p> </card> </wml>
  • 15.
    WML - Variables  Specify a variable with the Setvar command  <setvar name="i" value="500"/>  Specify a variable through an input element (like input, select, option, etc.) <card id="card1"> <select name=“opt"> <option value="HTML">HTML Tutorial</option> <option value="XML">XML Tutorial</option> </select> </card>  To use the variable we created in the example above: <card id="card2"> <p>You selected: $(opt)</p> </card> Dickson Chiu-2004 CSIT600b 03-15
  • 16.
    WML - Postingto the Server <!-- From: http://www.topxml.com/wap/articles/wml_jsp/default.asp --> <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" "http://www.phone.com/dtd/wml11.dtd"> Dickson Chiu-2004 CSIT600b 03-16 <wml> <card id="start" title="Weather"> <do type="accept" label="Go!" > <go href="weather.jsp"><!-- submitted to a JSP --> <postfield name="query" value="$query" /> <postfield name="QP1" value="$QP1" /> <postfield name="target" value="wml-$(query)" /> </go> </do> <p align="center">Weather Page</p> <p> Zip? <input name="QP1" format="*N" maxlength="10" value="" /><br /> Query? <select name="query"> <option value="TimeTemp" > time &amp; temp </option> <option value="AllTable" > all fields </option> <option value="AllText" > all fields format</option> </select> </p> </card> </wml>
  • 17.
    Generating WML withXSLT <!-- Available: http://kwchiu.dyndns.org:7999/xslt3.xsl --> <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <wml> <card> <table> <?xml version="1.0" encoding="UTF-8"?> <wml> <card> <table> <tr><td>CHEUNG KONG</td> <td>64.00</td></tr> </table> … </card></wml> Dickson Chiu-2004 CSIT600b 03-17 <xsl:for-each select="/hsiComponents/component"> <tr> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="lastTrade"/></td> </tr> </xsl:for-each> </table> </card> </wml> </xsl:template> </xsl:stylesheet> <?xml version="1.0" encoding="UTF-8"?> <hsiComponents> <component> <name>CHEUNG KONG</name> <lastTrade>64.00</lastTrade> </component> ... </hsiComponents>
  • 18.
    Dickson Chiu-2004 CSIT600b03-18 WAP Emulator  http://www.gelon.net/  Paste URL to WAP emulator:  http://kwchiu.dyndns.org:7999/html2dom/result?s ourceURL=http%3A%2F%2Ffinance.yahoo.com% 2Fq%2Fcp%3Fs%3D%5EHSI&xslt1URL=http%3A %2F%2Fkwchiu.dyndns.org%3A7999%2Fxslt1.xsl &xslt2URL=http%3A%2F%2Fkwchiu.dyndns.org %3A7999%2Fxslt3.xsl&submit=convert  More sophisticated development:  http://www.forum.nokia.com/main/0,6566,034- 521,00.html