The WML basics of the Wireless Markup Language (WML) Foundation

Source: Internet
Author: User
Tags format define empty end execution variables string variable

  in the previous section , we introduced the basic structure of the WML program, and then we introduced the basic knowledge of the WML language, mainly including the character set of WML, variables, data types, and the basic components of the WML program.

  1. The character set and coding of WML

WML uses the character set of XML, the universal Character set iso/iec-1062, or the unified character encoding standard Unicode 2.0. At the same time, WML also supports a subset of the other series's character sets, such as UTF-8, iso-8859-1, or UCS-2. which

UTF-8 refers to the conversion format 8 (Transformation Format 8) of the universal Character set UCS (Universal Character Set), which mainly transmits the conversion encoding of the international character set. UTF-8 uses the UCS character's 8-bit code to provide a very secure coding format that can effectively avoid eavesdropping, interception, and illegal decryption during data transmission. At the same time, UTF-8 is fully compatible with the 7-bit acsii code, which does not affect the program that this kind of coding implements, its coding rules are very strict, can effectively avoid synchronous transmission error, but also support other character sets provide enough space.

The iso-8859-1 character set is an extension set of the acsii character set developed by the International Organization for Standardization ISO (International Standardization organization) to represent the characters of all Western European languages. Like ISO Latin-1, Iso-8859-1 is very similar to the character set of the ANSI (American National Standards Institute), which is commonly used in the Windows environment, and in most cases does not need to be distinguished. In cases not specifically specified, the HTTP protocol uses the ISOLATIN-1 character set. Therefore, to represent a acsii (non-acsii) character in a WML page, developers need to use the corresponding ISO Latin-1 encoded characters.

The UCS-2 is a 2-byte (or 16-bit) encoding standard for a custom-defined universal 8-bit coded character set (Universal Multiple-octer coded Character set) in the standard. The character encoding value is equal to the standard encoding value of the Unicode character.

WML documents can be encoded using any character encoding standard defined by the HTML 2.0 specification. Generally speaking, the character encoding of a WML document needs to be converted to another encoding format to match the character standard used by the WAP user's mobile browser, otherwise the mobile browser will not be able to display characters from the WML page. However, some character information may be lost in the encoding conversion, so if the encoding conversion of the WML document is done on the client side, it may result in the loss of some result information and cannot be browsed by the user. Therefore, if necessary, we should try to complete the encoding conversion before the WML page is routed to the user's browser.

To address this problem, on the one hand, we need to supplement the Web server with the definition of WML data types, so that the server can accurately transfer the data, on the other hand, we need to develop code conversion principles.

  2. Use basic rules for WML characters

WML is a relatively strict language, character usage must follow the corresponding rules, these basic rules mainly include the following aspects:

1) Case sensitive. In WML, both the label element and the property content are case sensitive, which inherits the strict attributes of XML, and any capitalization errors can result in Access errors.

In general, all of the labels, attributes, rules and enumerations of WML and their acceptable values must be lowercase, and the card's name and variable may be uppercase and lowercase, but it is case-sensitive. Both the names of the parameters and the values of the parameters are case-sensitive, such as Variable1, Variable1, and vaRiable1 are all different parameters. 2) space. For consecutive null characters, the program needs only one space to run. There can be no spaces between the property name, symbol (=), and value.

3) label. The value of the property within the label must be enclosed in double quotes (") or single quotes ('). For a label that does not appear, you must precede the greater-than sign (>) with a forward slash (/), such as a newline label that must be written as <br/> correct.

4 does not display the content. In WML, characters that are not displayed consist mainly of line breaks, carriage returns, spaces, and horizontal tabs, and their 8-digit hexadecimal inner code is 10, 13, 32, and 9, respectively.

When the program executes, WML ignores all more than one display character, that is, WML converts one or more consecutive lines, carriage returns, horizontal tabs, and spaces into an empty space.

5) reserved characters. This is a special character of WML, such as less than (<), greater-than (>), single quote "'", double quote "", and Number (&).

6) display Chinese characters. If you want the WML program to be able to display Chinese characters when it executes, you only need to use the encoding to specify the character set at the beginning of the program. For example: <?xml version= "1.0" encoding= "gb2312" >.

Note: The form and method of specifying the character set may vary depending on the development tool or WAP phone.

  3, variable

Variables can be used in WML programming, and variables must be defined before they are used. Once a variable has been defined on a card in deck, the other card can call the variable without having to redefine it.

The syntax format for defining variables is:

$identifier
$ (identifier)
$ (identifier:conversion)

Where identifier refers to variable names, or variable identifiers; conversion refers to the substitution of variables.

Variable names are made up of us-acsii codes, underscores, and numbers, and can only begin with us-acsii code. Variable names are strictly case-sensitive, i.e., variable names are case sensitive.

The syntax for defining variables has the highest interpretation precedence in WML.

The instructions for using variables are as follows:

1 in WML, a variable can be used in a string, and the value of the variable can be updated in the run.

2 when the variable is equivalent to an empty string, the variable is in an unspecified state, that is, null (NULL).

3 When a variable is not equivalent to an empty string, the variable is set, that is, a non-empty (not null) state.

4 in the "$identifier" form, WML usually represents the end of the variable name with a space following the variable name. If in some cases a space cannot represent the end of a variable name, or if the variable name contains a space, you must enclose the variable name in parentheses, in the form of "$ (identifier)".

A variable in a WML program can be substituted, and we can assign the value of a variable to a text in the card. A description of the variable substitution is as follows:

1 in a WML program, only the text part can be substituted.

2 substitution generally occurs during the runtime, and the substitution does not affect the current value of the variable.

3 any label is implemented in the form of a string substitution.

4 substitution is achieved by means of string substitution.

Because a variable has the best precedence in the syntax, the string containing the variable declaration character is treated as a variable, so if you want the program to display the $ symbol, you need to use two "$" as a continuous description. For example:<p> Your Acconut has $$15.00 in it </p> the result of the sentence is: Your account has $15.00 in it.

  4. WML Core Data type

The core data types of WML are character data and are defined according to the data type of the XML, with a total of 2 of the following. Throw noise stop? 1 CDATA type. This data type is the most used for WML, and can be a number, a string, or a string that contains numbers. However, the definition, whether numeric or string, must be defined as text, and the data is enclosed in quotation marks. CDATA-type data is used only for attribute values. For example, "$ (value)" or name= "value", and so on. Note that the value here refers to a CDATA type of data value.

2) pcdata type. This is a class of data that is decomposed from CDATA, except that it can be a text-form number, a string, or a mixed string of both, and it can be a WML label. Pcdata data can only be used for the element representations of WML.

3) NmToken type. This is a special kind of data, which contains or partially contains numbers, letters and punctuation marks that are nmtoken data. This data can begin with a punctuation mark, but is not used to define variable or element names.

4) ID type. A data type that is specifically used to define the name of a WML element.

In this 2. The 珻 data type is flexible enough to make variables or data exempt from grammar checking. This is because the content of the data in CDATA is treated as text, which avoids the syntax checking of WML and is displayed directly as text.

  5. Properties of WML data value

In addition to NMTOKEN data, the other 3 types of data in WML must be defined in literal form, including quotation marks. The question we are concerned with is, what data values can these types of data represent? Or, what are the properties of the data values they represent? In fact, WML data can only be of length, macro variables (vdata), flows (flow), Insiders (Inline), Layout (Layout), text (text), Hyper-chain (HREF), Boolean values (Boolean), Data (number) or enhancement (emphasis).

  6. Card and card set

Before we analyzed the structure of WML programs, the information about WML documents was organized in the form of card sets and card sets. A deck is a collection of one or more card. When a client terminal makes a request, WML sends the deck from the network to the customer's browser, deck is the smallest unit of information sent by the server. After the user's browser receives the deck, you can browse all the card included in it. The card is used to represent or describe one or more user interaction units.

  7. Card Group Template

The same card group usually contains a number of cards, the definition, attributes or formats are usually the same. If we define each card individually, it is obviously very troublesome. To do this, WML provides the functionality of the card-group template, which defines a set of criteria and parameters that can be applied to all cards in the same card set, which can greatly improve our programming efficiency. The contents of the Card group template will be introduced later.

  8. WML and URL, program segment anchor

We know that the global network WWW is a network of information and equipment, to ensure global interaction, 3 kinds of specifications have been developed: first, the Uniform Resource Locator URL provides a standard naming and positioning method for all network resources; Secondly, the standard protocol, such as HTTP protocol, provides the transmission mode of WWW resources. , and its third. Standard content types, such as HTML, WML, provide content forms and standards for WWW resources. WML follows these specifications and expands the scope of the URLs used. In WML, not only the hyperlink, file path and filename can be used as URL processing, card name, macro variable name and various internal resource names can also be treated as a URL.

To do this, WML improves the way HTML named resources are positioned, using the form of a program anchor (Fragment anchor) to handle the status of a program in a WML program. The program segment anchor is defined according to the document WML rule and is written in the form of a good word (#) before the program segment representation. With program segment anchors, WML programs can position different cards in the same card set. If you do not specify a program segment in your program, the URL name referenced in the program refers to the entire card group, and the name of the card group is also the name of the first card in this card group.

  9. Browser Operation history

In order to manage the execution of WML programs at the browser end, WML uses the "browser-front" function to preserve the state of the WML program execution and various parameters, variables, etc., which can be used to record the user's operation. At the same time, WML also provides a simple navigation history model that records the various operations of the user browsing in the form of a URL address and puts these URL addresses into the historical push stack. By pushing the stack, users can realize the resurgence of historical browsing and other operations.



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.