|
|
Lesson 2: Introduction to WML
WML - the Wireless Markup Language - is the language now used to write content for WAP phones. The alternative, HDML (Handheld Device Markup Language), can be taken to be obsolete.
WML is a 'markup' language. This means that WML pages are written and saved as text files, using 'tags' like those found in HTML. Anyone familiar with HTML should find learning WML fairly easy.
There are, however, some important general differences between HTML and WML. These stem from the fact that WML is specified in XML (the eXtensible Markup Language). XML specifies a general way to define different types of markup languages, and has the following quirks:
- XML-specified languages are case sensitive. So, for instance, a tag <Wml> is different from a tag <wml>. This is unlike HTML, where case is generally ignored.
- XML-specified languages are strict. Most HTML editors are very forgiving about badly coded HTML pages, and do their best to show some content. WML editors, however, will just report an error if given a badly coded WML page.
- All the attributes of elements must be contained within either double (") or single (') quotes. This is slightly different from HTML where attributes need not be contained within quotation marks for most browsers.
- One way in which WML is strict is that all tags crave closure. For instance, an opening <wml> tag must have a closing </wml> tag. Some tags don't come in pairs and are allowed to close themselves; these must have a forward slash at the end of their text, like <br/>
The following script doesn't contain any viewable content, but demonstrates the elements that every WML page should have. The line numbers are given just for our benefit, and shouldn't be included in an actual script.
|
1.
|
<?xml version="1.0"?>
|
|
2.
|
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
|
|
3.
|
<wml>
|
|
4.
|
</wml>
|
|
|
Line 1 identifies that the document is written in the finalised version of XML.
Line 2 states that the document is a WML document of version 1.1, which is the current standard. Until the newer versions of WAP are introduced, you can just copy lines 1 and 2 for each WML document you produce. Lines 3 and 4 contain the opening <wml> tag, and the closing </wml> tag. There can only be one such pair of tags in any single WML document, and everything else in your WML document must be placed between these tags.
|
|
|
|