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.
2.3 Basic knowledge of WML language
In the previous section, we introduced the basic structure of WML programs. Next, we introduced the basic knowledge of the WML language, mainly including the character set, variables, data types and basic components of WML programs.
2.3.1 WML character set and encoding
WML uses XML's character set, that is, the general character set ISO/IEC-1062., which is the unified character encoding standard Unicode 2.0. At the same time, WML also supports subsets of character sets in other series, such as UTF-8, ISO-8859-1, or UCS-2, etc. in:
UTF-8 refers to the transformation 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 adopts 8-bit encoding of UCS characters, providing a very secure encoding format, which can effectively avoid eavesdropping, interception and illegal decryption during data transmission. At the same time, UTF-8 is fully compatible with 7-bit ACSII code and will not affect the programs implemented in this type of encoding; its encoding rules are very strict, which can effectively avoid synchronous transmission errors, and it also supports other character sets to provide sufficient space.
The ISO-8859-1 character set is an extended set of the ACSII character set formulated by the International Organization for Standardization ISO (International Standardization Organization), which can represent characters in all Western European languages. Like ISO Latin-1, ISO-8859-1 is very similar to the character set of the American National Standards Institute (American National Standards Institute), which is commonly used in Windows environments, and does not need to be distinguished in most cases. The HTTP protocol uses the ISOLatin-1 character set without being specified. Therefore, in order to represent non-ACSII (non-ACSII) characters in the WML page, developers need to use the corresponding ISO Latin-1 encoded characters.
UCS-2 is a 2-byte (i.e., 16-bit) encoding standard for the custom universal multi-8-bit encoding character set (Universal Multiple-Octer Coded Character Set) in ISO 1062. The character encoding value is equal to the standard encoding value of Unicode characters.
WML documents can be encoded using any character encoding standard defined by the HTML 2.0 specification. Generally speaking, the character encoding of WML documents needs to be converted into another encoding format to adapt to the character standards used by the mobile browser of WAP users. Otherwise, the mobile browser will not be able to display the characters in the WML page. However, some character information may be lost during encoding conversion. Therefore, if the encoding conversion of WML documents is performed on the user side, some result information may be lost and cannot be browsed by the user. Therefore, if necessary, we should try to complete the encoding conversion before the WML page is delivered to the user's browser.
To solve this problem, on the one hand, we need to supplement the WML data type for the web server so that the server can accurately transmit this data. On the other hand, we need to formulate the principles of encoding and conversion.
2.3.2 Basic rules for using WML characters
WML is a relatively strict language, and the corresponding rules must be followed in character use. These basic rules mainly include the following aspects:
1) Case sensitive. In WML, both the tag elements and the content of the attribute are case sensitive, which inherits the strict characteristics of XML, and any case errors can lead to access errors.
Generally speaking, all tags, properties, regulations and enums of WML and their acceptable values must be lowercase, and Card's names and variables can be uppercase and lowercase, but it is case sensitive. The name of the parameter and the value of the parameter are case sensitive, such as variable1, Variable1 and variable1 are all different parameters. 2) Spaces. For consecutive null characters, the program only needs one space when running. There cannot be spaces between attribute names, symbols (=) and values.
3) Tags. The values of attributes in the tag must be enclosed in double quotes (") or single quotes ('). For labels that do not appear in pairs, a slash (/) must be added before the sign (>). For example, the new line label must be written as <br/> to be correct.
4) Content not displayed. In WML, characters not displayed mainly include line breaks, carriage return, spaces and horizontal tabs, and their 8-bit hexadecimal codes are 10, 13, 32 and 9 respectively.
When the program is executed, WML will ignore all more than one undisplayed characters, that is, WML will convert one or more consecutive line breaks, carriage returns, horizontal tabs and spaces into one empty one.
5) Reserve characters. These are some special characters in WML, such as less than sign (<), greater than sign (>), single quote "'", double quote """, and sum (&).
6) Display Chinese characters. If you want the WML program to be able to display Chinese characters when executing, you only need to use encoding to specify the Chinese character set at the beginning of the program. For example: <?xml version="1.0" encoding="gb2312">.
Note: The form and method of specifying a Chinese character set may vary depending on the development tool or WAP phone.
2.3.3 Variables
Variables can be used in WML programming, and variables must be defined before use. Once a variable has been defined on one of the cards in the Deck, the other cards can be called directly without redefining it.
The syntax format for defining variables is:
$identifier
$(identifier)
$(identifier:conversion)
where identifier refers to the variable name, or variable identifier; conversion refers to the substitution of variables.
Variable names are composed of US-ACSII codes, underscores, and numbers, and can only start with US-ACSII codes. Variable names are strictly case sensitive, that is, variable names are case sensitive.
The syntax for defining variables enjoys the highest interpretation priority in WML.
The instructions for using variables are as follows:
1) In WML, variables can be used in strings, and the value of the variable can be updated during runtime.
2) When the variable is equivalent to an empty string, the variable will be in an unset state, that is, empty (Null).
3) When the variable is not equal to an empty string, the variable will be in the set state, that is, the non-null state.
4) In the form of "$identifier", WML usually indicates the end of the variable name with a space after the variable name. If in some cases the space cannot represent the end of a variable name, or the variable name contains spaces, the variable name must be enclosed in parentheses, that is, in the form of "$(identifier)".
Variables in WML programs can be replaced, and we can assign the value of the variable to a text in the Card. The following descriptions of variable substitutions:
1) In WML programs, only text parts can be replaced.
2) Substitution usually occurs during the runtime, and substitution will not affect the current value of the variable.
3) Any tag is implemented in a string substitution way.
4) Substitution is implemented in the form of string substitution.
Since variables have the best priority in syntax, strings containing variable declaration characters will be treated as variables, so if you want to make the program display the "$" symbol, you need to use two "$" in succession for explanation. For example: <p> Your acconut has $$15.00 in it </p>The result displayed by one sentence is: Your account has $15.00 in it.
2.3.2. WML core data type
The core data types of WML are all character-type data, and are defined according to the XML data types. There are 2. Noisy stops? 1) CDATA type. This data type is the most commonly used WML, and can be a number, a string or a string containing a number. However, when defining, whether it is a number or a string, it must be defined in text form and the data is enclosed in quotes. CDATA type data is only used for attribute values. For example, "$(value)" or name="value" etc. Note that the value here refers to the data value of the CDATA type.
2) PCDATA type. This is a type of data decomposed from CDATA. In addition to being a number, a string or a mixed string of both, it can also be a WML tag. PCDATA type data can only be used for element representation of WML.
3) NMTOKEN type. This is a special type of data. All data containing or part of numbers, letters and punctuation marks belong to NMTOKEN type data. This kind of data can be started with punctuation, but is not used to define variable names or element names.
4) Id type. A data type specifically used to define the name of a WML element.
In this 2. Noisy elliptical DATA type is more flexible to use, it can save variables or data from syntax checking. This is because the data content in CDATA will be processed as text, which can avoid WML grammar checking and directly display it as text.
2.3.5 WML data value properties
In addition to NMTOKEN type data, the other three WML data must be defined in text form, i.e., quotation marks. The question we are concerned about is, what data values can these types of data represent? Or, what is the nature of the data values they represent?
In fact, WML data can only be length (Length), macro variable (Vdata), stream (Flow), inline (Inline), layout (Layout), text (Text), hyperchain (Href), Boolean, data (Number), or enhanced mode (Emphasis).
2.3.6 Cards and Card Sets
When we analyzed the structure of WML programs, we will talk about the information of WML documents being organized in the form of card sets and card sets. A Deck is a collection of one or more cards. After the client terminal issues a request, WML sends the Deck from the network to the client's browser, and the Deck is the smallest unit of information sent by the server. After the user's browser receives the Deck, he can browse all the cards included. Card is used to represent or describe one or more user interaction units.
2.3.7 Card Set Template
The same card set usually contains many cards, and the definitions, attributes, or formats of these cards are usually similar. If we define each card one by one, it will obviously be very troublesome. To this end, WML provides the function of a card set template. A series of standards and parameters are defined in the template, which can be applied to all cards of the same card set, thereby greatly improving our programming efficiency. We will introduce the content about card set templates later.
2.3.8 WML and URL and program block anchor points
We know that Global Network WWW is a network of various information and devices. In order to ensure global interaction, people have formulated three specifications: First, the unified resource locator URL provides standard naming and positioning methods for all network resources; second, standard protocols, such as HTTP protocol, provide transmission methods for WWW resources; third. Standard content types, such as HTML and WML, provide content forms and standards for WWW resources. WML follows these specifications and expands the scope of URL usage. In WML, not only the hyperconnection, file path and file name can be processed as URLs, but card names, macro variable names and various internal resource names can also be processed as URLs.
To this end, WML has improved the way HTML naming resource locations and uses program anchors (Fragment Anchor) to handle the status of a certain program in a WML program. The anchor points of the program block are defined according to the WML rules of the document and are written in a way that the tic toe is added (#) before the program block symbol. Using block anchors, WML programs can locate different cards in the same card set. If the program segment is not specified in the 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 the card group. 2.3.9 Browser operation history
In order to manage the execution of WML programs on the browser side, WML uses the function of "browser front and back relationship" to save the execution status of WML programs and various parameters, variables, etc., so that it can be used to record the user's operation status. At the same time, WML also provides a simple navigation history model, which records various actions when users browse in the form of URL addresses, and puts these URL addresses into the history push stack. By pushing the stack, users can realize the resurgence of historical browsing and other operations.
Previous page12Read the full text