- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
These days, cell phone makers are building phones that can display XHTML, graphics, even animations. But it wasn't always this way, and a large percentage of the phones already in circulation still use XHTML Mobile Profile's predecessor (well, one of them, anyway), Wireless Markup Language, or WML. So that's where we'll start the discussion of cell phones and using them with XML.
WML is based on a "card" metaphor -- yes, like Hypercard, for those of you actually old enough to remember it -- which enables the phone to download a "deck" and display multiple pages without having to make multiple calls to the server. For example, I can create a simple deck such as:
<?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="c1" title="First"> <p> This is the first card. Select <a href="#c2">this link</a> for the second card. </p> </card> <card id="c2" title="Second"> <p> This is the second card. </p> </card> </wml>
If I load this deck into a phone (or a simulator, as I'm doing here), the first card shows, as you can see here in figure 1:
If I highlight the link (in the simulator, by pressing the down button) and then select it (by
pressing the left-most button under the LCD screen) the phone takes me to the location specifed
as #c2
. In an HTML page, that would be an internal link on the page, or
in XHMTL, it would refer to an element with an id
of c2
. In
WML, it's both; we are taken to the card identified as c2
, as you can see
here in figure 2:
Now, that takes care of the general structure of a WML file, but you might be wondering
just what you can actually do with one of these things. It turns out that the answer
is "quite a bit, actually." WML supports basic formatting, such as <em>
(emphasis, typically rendered as italic), <strong>
(typically rendered as bold)
<b>
(bold), <i>
(italic), <u>
(underline), <big>
,
and <small>
, as well as <p>
(as you've
already seen) and <br />
, but it also does more than that; it enables you to
get input from the user, and to use variables.
For example, I can build the classic "Hello World!" page:
<?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="c1" title="First"> <do type="accept" label="Answer"> <go href="file://e:/phone/testcard.wml#c2"/> </do> <p> Enter your first name:<br /> <input name="yourname" /> </p> </card> <card id="c2" title="Second"> <p> Hello, $(yourname)! </p> </card> </wml>
This starts us out with a page like Figure 3:
In this case, I've got an input
element -- note that a form
element isn't
necessary -- and I've added a do
action.
When the user "accepts" the
entry -- on the simulator, that means clicking "Done", then "Options", and selecting the Answer
entry -- the variable yourname
gets set. The phone then goes on to
c2
, and displays the information, as you can see in Figure 4.
You can also provide a list of options, such as:
<?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="c1" title="First"> <do type="accept" label="Answer"> <go href="file://e:/phone/testcard.wml#c2"/> </do> <p> I'm interested in authoring in: <select name="languagetype"> <option value="WML">WML</option> <option value="XHTML-MP">XHTML-MP</option> <option value="XHTML-Basic">XHTML-Basic</option> </select> </p> </card> <card id="c2" title="Second"> <p> Don't worry, we have lots of tutorials on $(languagetype)! </p> </card> </wml>
When you load this deck, the actual display will vary depending on the phone. Some phones will display radio buttons. The simulator renders this as a numbered list, as you can see in figure 5:
When you choose an entry by pressing a number, the phone carries out the appropriate action:
Of course just moving around in the deck is of limited use. Sooner or later,
you're going to want to actually interact with a server. To do that, you'll need
to send information. For example, we can build the above form to send the choice
to a server, which can then send back the appropriate content. To do that, we'll
need to use a postfield
:
<?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="c1" title="First"> <do type="accept" label="Answer"> <go href="http://www.nicholaschase.com/informit/tutorials.wml" method="post"> <postfield name="tutorialset" value="$(languagetype)"/> </go> </do> <p> I'm interested in authoring in: <select name="languagetype"> <option value="WML">WML</option> <option value="XHTML-MP">XHTML-MP</option> <option value="XHTML-Basic">XHTML-Basic</option> </select> </p> </card> </wml>
In this case, we don't need a second card, because the phone will go to the
url http://www.nicholaschase.com/informit/tutorials.wml
when the
user makes a choice, substituting the appropriate languagetype
value
as the value to submit. (You can also use postfield
with a get
request.)
Meant for devices with only a small amount of computing power, WML is pretty simple. There's a little more to it, including the ability to do simple scripting and form validation, but for the most part, this is it.
(Openwave and the Openwave logo are registered trademarks and/or trademarks of Openwave Systems Inc. in various jurisdictions. All rights reserved.)