WML Tutorial 1: A comprehensive understanding of WML from the first practical application

Source: Internet
Author: User
Tags cdata closing tag include variables prev variable
Tutorial

The best way to learn natural language is to dissolve into the corresponding language environment in the exchange of learning, the best way to learn a programming language is to see routines. To help create a first impression of WML applications, let's take a look at the first 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>
<do type= "prev" label= "Back" >
<prev/>
<!--provide a button can clink to back a step-->
</do>
</template>
<card id= "Friends" title= "hot link" >
<p>
<a href= "Sina ' >http://wap.sian.com.cn/" >sina wap</a><br/>
<a href= "#nextcard" >next card</a>
</p>
</card>
<card id= "NextCard" >
<p>
This is the second card.
</p>
</card>
</wml>

From the above example, you should know the following:

1, Syntax: WML syntax is similar to HTML, is still a markup language, and continues the XML syntax rules

2. Elements: in XML and WML languages, the basic elements of a language are called "tags."
tags must be enclosed by < and >.
Most labels include the "Up" and "stop" parts, such as:<p>...</p>
Some special tags can have only one label, but must have a closing tag, such as:<prev/>

3, Attributes: XML language tags can contain many attributes, to provide the necessary additional information to the label
Property content is usually used within the start tag
Property only provides the necessary information for the label as a parameter and is not displayed by the browser
The value of the property needs to be enclosed in quotation marks, either single or double quotes, which can be nested using
For example: <card id= "Friends" title= "hot link" >

4, Notes
Annotation content is convenient for the creator to read the source code, will not be displayed by the browser
WML does not support annotation nesting
For example:<!--This is a comment. -->

5. Document Structure
WML documents are composed of card and deck, and a deck is a collection of one or more card. After receiving a client terminal request, WML sends deck from the network to the customer's browser, and visitors can browse through all the card included in the deck without having to download each card individually from the web.

Some of the other examples don't include the basics:

6, Case sensitive
Both the label element and the property content are case-sensitive, which inherits the strict nature of XML, and any capitalization errors can cause access errors, a problem that WML producers must pay attention to.


7, evade the grammar examination method-cdata
CDATA The contents of the data are treated as text, bypassing the grammar checker and displaying it directly as text.
Example:
<! [CDATA [This IA <b> a test]] >
Display results as
This IA <b> a test

8. Define Variables
WML can use variables for browsers and script use, and by setting a variable on a card in deck, the other card can be invoked directly without having to reset it.

The syntax for the variable is as follows:
$identifier
$ (identifier)
$ (identifier:conversion)

If the variable content contains spaces, it needs to be enclosed in parentheses. Because variables have the highest precedence in syntax, strings containing variable declaration characters are treated as variables, so if you want to display $, you must use two $ in a row.

Example:
<p> Your account has $$15.00 in it.</p>
Display Result: Your account has $15.00 in it

XML is a language that is very strict in syntax, and WML inherits this rule, and any nonstandard syntax can lead to errors.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.