Well, not really—rather Frequent WAP 1.1 Mistakes.
An entire generation has been brought up with the anything goes
attitude of Microsoft®/HTML.
Now, with XML, they are back to the good days, before Internet Explorer and
FORTRAN,
when things were supposed to be done right,
not just happen to work on some random test platform.
Almost all WAP pages that do not work on real phones, contain one of the following 4 mistakes: Beginning with Whitespace, omitted encoding specification, wrong MIME type or invalid code. (There is also a little PHP problem.)
With a few exceptions that are probably not relevant for WAP, all XML files shall start with the two characters <?
.
(On a binary level, they should start with the 16 bits that represent <?
in US-ASCII, ISO-8859-1, UTF-8 and many other encodings.)
The page can't start with space, linefeed, comments or any other junk that ASP, Cold Fusion and PHP usually place at the start of a page, because that used to be acceptable for HTML browsers.
There are rules for determining default encoding, both in HTTP and in XML. Forget them. They don't work.
Specify encoding explicitly. With a plain editor, you should probably use ISO-8859-1:
<?xml version="1.0" encoding="ISO-8859-1"?>
With a Unicode capable editor, you should probably use UTF-8:
<?xml version="1.0" encoding="UTF-8"?>
Never use:
<?xml version="1.0"?>
The MIME for WML pages is text/vnd.wap.wml.
For WAP 2 pages, like the one you are reading now, I have to confess some ignorance. (I have no WAP 2 capable phone.) Such pages don't use WML, but XHTML Mobile Profile. Some sources say application/xhtml+xml. But I use text/html to keep compatible with web browsers.
<% Response.ContentType = "text/vnd.wap.wml"; Response.Charset = "utf-8"; %>;
<? header("Content-Type: text/vnd.wap.wml;charset=utf-8"); ?>
<cfcontent type="text/vnd.wap.wml">
(I must remember to check if I can specify encoding in this element.)
Make sure your code is valid, i.e. conforming to a WAP DTD.
A good start for a WAP page:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml>
PHP will try to execute an XML declaration like <?xml version="1.0" encoding="iso-8859-1"?>.
If this is coded as <? echo'<?xml version="1.0" encoding="iso-8859-1"?>'?>, it should work in PHP.
WAP emulators are good for testing WAP page usability. But they often allow errors in the code to pass unnoticed. Even when they do strict validation, they are overkill.
The Opera web browser can read WML. It doesn't do strict validation, but will detect some errors, and allows you to see the WML source. (But be aware that Opera doesn't state acceptance of text/vnd.wap.wml in its HTTP request—if you do content negotiation between HTML and WML, you will get problems with Opera.)
The HTTPtest lets you see the response from a publicly available page.
HTTPLook lets you see what is returned from a local or public WAP page to your Opera browser or HTTP based emulator. (It will not let you see the communication between an emulator and a WAP gateway.)
W3C validates pages against WAP (and other) DTDs
XMLSpy validates and edits WAP (and other XML)
Openwave SDK 5.1 gives good error messages for whitespace at the beginning of the page.
More FAQs: thewirelessfaq.com