Through the above examples, we can understand the structure and composition of WML programs:
1) Syntax. WML is very similar to HTML. It is still a markup language and continues the grammar rules of XML. We will encounter specific grammars in the future in the learning process.
2) Document statement. All WML programs must declare XML file types at the beginning of the file, including the XML version, WML document types, specifications used, etc. The declaration form is as follows:
<?xml version="1.0">
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
3) Tags. Tags (Tags) are required in WML languages, and their usage forms are exactly the same as those in markup languages such as HTML and XML.
4) Elements. The element of WML is used to describe the tag information of the card group (Deck), that is, structure information. An element usually consists of a first label, content, other elements and a tail label, and has one of the following two structures:
<First Tag>Content</Term Tag>
or
<Tags/
The content contained in the element can also include elements, which also consist of the first label, corresponding content, other elements and tail labels. Elements that do not contain content become empty elements. It is a separate tag. In other words, individual labels are also an element.
5) Attributes. Like XML, WML can contain many attributes. Attributes are used to provide the tag with necessary additional information, and the attribute content is usually used within the starting tag. However, the attribute content will not be displayed by the browser, and it serves as a parameter to provide the necessary information for the tag.
When specifying the value of an attribute, the value needs to be extended in quotes, which can be single or double quotes, and quotes are usually used in pairs. The attribute name must be lowercase. For example: <card ontimer="#card2" title="Toolkit Demo">
Moreover, the single quote attribute can also contain double quote attributes. Entity characters can also be used as attribute values. Entity characters refer to special characters such as &, <,>, ', ". In WML programs, they need to be processed in special processing. We will introduce specific methods later.
6) Comments. Comments can also be added to WML programs. Comments are used to facilitate developers to read the source code smoothly, and they will not be displayed by the browser. Comment content is introduced in the tag with exclamation mark (!) and used in the form of <!--Comment content-->. For example: <!-- Write your card implementation here.-->. It should be noted that nesting of comments is not supported in XML programs.
7) Document structure. A WML document is composed of "cards" and "Decks", a Deck is a collection of one or more cards. After the client makes a request, WML sends the Deck from the network to the client browser. This is where the user can browse all the cards contained in the Deck without having to download each card separately from the network. The first card in the program is the card that is visible by default.
Note: Deck means a deck of cards, here it refers to a stack of cards, so we call it "card set" here. In addition, Card refers to a web page with the size of a WAP mobile phone. Although sometimes a Card may require multiple screens to be displayed, we can also translate it into "page", but this is easy to mix with pages in HTML. So we call it a card here.
2.2.3 The basic structure of WML programs
The above has briefly analyzed the program structure and composition of WML, so you can have a comprehensive preliminary understanding of WML programs. Below we give the basic structure of the WML program.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.1xml">
<wml>
<head>
<access/>
<meta..../>
</head>
<card>
Some contents...
</card>
<wml>
This basic structure can be divided into the following key parts:
1) Statement. A WML program consists of many Decks. For each Deck, an XML declaration and a document type DOCTYPE declaration must be performed at the beginning of its document.
XML declarations are always on the first line of the file. Note that it is best not to have spaces in front or it is OK:
<?xml version="1.0"?>
2) Immediately following is the DOCTYPE declaration, please note that the declaration is the upper and lower case of the letters and don't make mistakes:
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.1xml">
3) <xml> tag. This tag is used to contain and define a Deck of WML. 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.
4) <head> tag. This tag is used to contain and define information about Deck. The <head> tag can contain one <access> tag and multiple <meta> tags.
5) <access/> tag. Its general form is <access domain="domain" path="/path"/>, which is mainly used to formulate the access control information of the current Deck, and has two optional attributes. Among them, domain is used to define the domain, the default value is the current domain, and path is used to define the path, and the default value is "/", that is, the directory. Since <access> is used alone, it needs to end with "/". Later, we will also systematically explain various WML tags. It doesn't matter if you can't understand it here, but it's mainly just a bit of emotional understanding.
6) <meta...> tag. Its general form is <meta attribute content="value" scheme" format forua="true|false"/>, which is used to provide the meta information of the current Deck, including memory data processing methods, data transmission methods and processing methods. We will give the details of this tag specifically later.
7) <card> tag. A Deck can contain multiple cards, and the content of each card may be displayed more than one screen. For each card, WML uses <card> and </card> for inclusion and definition. <card> can also contain multiple optional attributes, such as <card title="label" newcontext="false" ordered="true" onenterforwand="url" pmemterbackward="url" ontimer="url">. As for the specific meaning and functions of these attributes, we will introduce them later.
Previous page123456Next pageRead the full text