Software Sue

Link to Simply Sue
Link to Sustainability Sue
location: software/markup/wap/basics Skip navigation : Home  

WAP basics


Any text editor can be used to create WML pages. Note that WML is a specific type of XML language, so XML goes in the header.

The following should be inserted in all WAP pages:

<?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 where your code should go.
</wml>

Deck of Cards

WAP code is structured as a 'deck' of 'cards', each card small enough to load into the mobile phone's limited memory. Phones can cache multiple cards for future use. There are usually 1 to 3 cards per document, and mobile phone browsers read one card at a time. Each deck may have a template to define common characteristics for each of the cards within that deck. The WAP enabled browser will look for the start and end of each card in a wml document. You tell it using a <card> tag, which includes the name of the card for linking from one card to another, and the title. Your code should go between <wml> and </wml>. For example:

<?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<template>
</template>
<card id="card1" title="WAP Card 1">
     <p>
      This is a WAP page
     </p>
     <p>
       <a href="#card2">This take you to the second card</a>
      </p>
   </card>
  <card id="card2" title=" WAP Card 2">
      <p>
       This is the second wap card!
      </p>
      <p>
       <a href="#card1">Go back to card 1</a>
      </p>
    </card>
</wml>

The id attribute gives the card a name, in this case "card1". This is so you can provide a link to other cards in your deck - much like the <a name="name1"> attribute in HTML. As the mobile phone browsers are only able to read one card at a time, you will have to provide links to enable your reader to find the other cards!

The <a> tag can link to the first card of another page, as well as another card:

   <a href="links.wml">Link</a>

or to another card on another page:

   <a href="links.wml#card2">Link to card 2</a>

The first card a user sees should be at the top, but the order of the rest does not matter.

The template is used for specifying the layout of any buttons you may want to be common between all the cards.

Buttons

Buttons are added using the tag. The 'type' attribute tells the phone which button you want to perform the action. All phones implement the WAP standard differently, however, so it is not always possible to label a button the way you want. On some phones, for example, the action may be added to the option list instead.

Trying to add an action to the Previous button

<do type='prev' label='Follow'>
  <go href='previous.wml'/>
</do>

Adding a back button

As mobile phones don't always have back buttons, you can add one as shown below. Put it above the cards to have it appear in all cards, or at the top of the card to have it appear just the once.

<template>
     <do type="accept" label="Back">
       <prev/>
     </do>
</template>
  <card id="card1" title="WAP Card 1">
     <p>
      This is a WAP page
     </p>
     <p>
       <a href="#card2">This take you to the second card</a>
      </p>
   </card>

Templates

The templates allows you to add characteristics, such as back buttons, to all the cards in a deck. For example:

<template>
     <do type="accept" label="Back">
       <prev/>
     </do>
</template>

In the above example, <prev/> tells the phone to go back a page, using its history. The tells the phone to add this action to the phone's 'prev' button - which it may or may not do.

Other basic features

The <b> (bold) element is commonly used.

Comments are written using <!-- -->

Some of the rules for wml:

The ONLY non numeric entities supported by wml are:

   &quot;(&#34;)quotation mark:"
   &amp;(&#38;)ampersand:&
   &apos;(&#39;)apostrophe:'
   &lt;(&#60;)less than:<
   &gt;(&#62;)greater than:>
   &nbsp;(&#160;)non-breaking space:[ ]
   &shy;(&#173;)soft hyphen:­