xml programming wml by dickson k.w. chiu phd, smieee
DESCRIPTION
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE. This presentation contains topic like.., XML Programming WML, Wireless Application Protocol (WAP), Wireless Markup Language (WML), Generating WML with XSLT, WAP Emulator,TRANSCRIPT
1
Dickson K.W. ChiuPhD, SMIEEE
Thanks to Prof. S.C. Cheung (HKUST)
CSIT600b: XML Programming
WML
Dickson Chiu-2004 CSIT600b 03-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). 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.
Dickson Chiu-2004 CSIT600b 03-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.
See: http://www.w3schools.com/wap/default.asp
Welcometo
MTM515!!
Emulator - http://ttemulator.com/
Dickson Chiu-2004 CSIT600b 03-4
WML – One CardText 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">
<wml>
<!-- THIS IS THE FIRST CARD IN THE DECK --><card id="start" title=“S.C. Cheung WAPSITE"><p>Welcome to MTMI515!!</p></card>
</wml>
Dickson Chiu-2004 CSIT600b 03-5
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-6
WML – Two CardsAttributes 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-7
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">
<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 <ahref="#pic">Picture</a>.</small></p></card>
Dickson Chiu-2004 CSIT600b 03-8
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>
</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>
Dickson Chiu-2004 CSIT600b 03-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-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">
Dickson Chiu-2004 CSIT600b 03-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">
<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>
Dickson Chiu-2004 CSIT600b 03-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-16
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"><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 & temp </option> <option value="AllTable" > all fields </option> <option value="AllText" > all fields format</option> </select> </p> </card></wml>
Dickson Chiu-2004 CSIT600b 03-17
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> <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>
<?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-18
WAP Emulator
http://www.gelon.net/ Paste URL to WAP emulator:
http://kwchiu.dyndns.org:7999/html2dom/result?sourceURL=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