SoFunction
Updated on 2025-04-07

WML Learning Second Basic Format and File Header

Basic format and file header
General format of wml file:

<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1."> 
<wml> 
<head> 
<access/> 
<meta..../> 
</head> 
<card> 
Some contents... 
</card> 
<wml> 

The structure looks very similar to an HTML file. For each DECK, the following type declaration must be specified at the beginning of its document:
<?xml version="1.0"?> 
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1."> 
Pay attention to the upper and lower case of letters. For a DECK, the file size is best not to exceed 1.2K.

The <wml> tag is the same as the <html> tag in HTML, which is used to indicate that this is a WML DECK. It has an optional xml:lang attribute to formulate the language of the document. For example, <wml xml:lang="zh"> means that the document language is Chinese.

Like HTML, the <head> tag contains relevant information about the DESK. <head> The tag can contain one <access> tag and multiple <meta> tags.

<access domain="domain" path="/path" /> is equivalent to the <BASE> tag in HTML, which specifies the access control information of the DECK. It uses two optional attributes. domain is used to specify the domain. The default value is the current domain. The path is used to specify the path. The default value is "/", that is, the root directory. Since <access> is used alone, it should be used/end, and I will not repeat it in the future for similar situations.

<meta attribute content="value" scheme="format" forua="true|false"/> Similar to HTML, it provides meta information for this DECK. Attributes are required, including the following three situations
name="name"  Server ignores meta data
http-equiv="name"  Server converts meta data into HTTP response header (same as HTML)
user-agent="agent"  Server directly passes the meta data to the mobile phone device. The content attribute is also a must, and its content depends on the attribute. The scheme attribute is not currently supported. forua is an optional attribute, specifying whether the <meta> tag is deleted by the intermediate proxy before the wml file is transmitted to the client (because the transmission protocol may change), the default value is false.

Currently supported meta data:
<meta http-equiv="Cache-Control" content="max-age=3600"/>Specify the storage time period for DECK in the mobile phone memory cache. The default is 30 days (unless the memory is exhausted). During this period, the mobile phone calls the accessed DECK directly from the cache. If the information is time sensitive, you can use max-age to specify the lifetime of the DECK in the cache, the minimum unit is seconds. If it is specified as 0, the DECK needs to be called by connecting to the server every time.

<meta user-agent="" content="false"/> and <meta user-agent="" content="Specified URL"/> are similar to the bookmarking functions of ordinary browsers. When the user bookmarks a CARD, the mobile browser first records the CARD with a tag. The default value of this tag is the title attribute in the <card> tag (which will be discussed later). Then, when the user selects the bookmark, the browser will open the recorded URL. However, because by default, the mobile phone will record all DECKs, so <meta> is generally used to prevent the mobile phone from recording the current URL, i.e.
<meta user-agent="" content="false"/>. In addition, if you want to specify a URL different from the current DRECk for the bookmark, use <meta user-agent="" content="specified URL"/>.

A DECK can contain multiple CARDs, and the content of each CARD may be displayed more than one screen. Pay attention to the relationship between DECK, CARD and screen display range. A CARD is included with <card> and</card>. <card> can contain the following optional properties:
<card  title="label" newcontext="false" ordered="true" onenterforward="url" onenterbackward="url" ontimer="url"> 
The *id attribute is used to specify the name of the CARD and can be used to jump between CARDs, which is equivalent to using <A NAME="jumpHere"> when jumping within the page in HTML.
*Title attribute is used as a bookmark mark, and this attribute is generally not displayed on the screen.
The *newcontext attribute, the default value is false, is used to indicate whether the phone needs to clear the previously retained information when jumping to this CARD, including variables, history records in the stack, reset the phone status, etc.
*ordered attribute, the default value is true, indicating whether the content in the CARD is displayed in a fixed order or according to user's choice. This is different from HTML. The content on the CARD page can be displayed in a certain order. The default is to display in linear order, that is, in the order of codes. However, it should be noted that the following three tags must be written in the following order <onevent> <timer> <do> (This is related to the "event" to be discussed later). This is done to facilitate filling of the form. When ordered is set to true, if the content of a form cannot be displayed in one screen, it will be divided into multiple screens. When ordered is set to false, the phone can display a summary CARD to summarize the valid options, and users can select the form options from it to fill in.
*onXXX attribute, similar to the onXXX attribute in HTML tags, is used to capture events. When the event is triggered, the specified operation (task) is performed, and here it is to turn to a certain URL.